@@ -12,35 +12,27 @@ module Coordinates =
1212 abstract member lat: unit -> float
1313 abstract member lng: unit -> float
1414
15- type [<Pojo>] Position = {
16- lat: float
17- lng: float
18- }
15+ [<Emit( " new window.google.maps.LatLng($0, $1)" ) >]
16+ let newLatLng ( lat : float , lng : float ) : LatLng = jsNative
1917
20- let newPos lat lng =
21- { lat = lat
22- lng = lng }
2318
24- type [<Pojo>] Bounds = {
25- NE : Position
26- SW : Position
27- }
28-
2919 // https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngBounds
3020
3121 type LatLngBounds =
32- abstract member extend : U2 < LatLngBounds , Position > -> LatLngBounds
33-
34- [<Emit( " new window.google.maps.LatLngBounds()" ) >]
35- let newLatLngBounds () : LatLngBounds = jsNative
22+ abstract member extend : LatLngBounds -> LatLngBounds
23+ abstract member extend : LatLng -> LatLngBounds
3624
3725 [<Emit( " new window.google.maps.LatLngBounds($0, $1)" ) >]
38- let newLatLngBoundsWith ( sw : U2 < LatLng , Position >, ne : U2 < LatLng , Position >) : LatLngBounds = jsNative
26+ let newLatLngBounds ( sw : LatLng , ne : LatLng ) : LatLngBounds = jsNative
27+
28+
29+ [<Emit( " new window.google.maps.LatLngBounds()" ) >]
30+ let newEmptyLatLngBounds () : LatLngBounds = jsNative
3931
4032module Places =
4133
4234 type [<Pojo>] Geometry = {
43- location: Coordinates .Position
35+ location: Coordinates .LatLng
4436 }
4537
4638 type [<Pojo>] Place = {
@@ -55,22 +47,28 @@ type RCom = React.ComponentClass<obj>
5547type MapRef ( mapRef ) =
5648
5749 /// Get the current bounds of the Map
58- member __.GetBounds () : Coordinates.Bounds =
59- let bounds = mapRef?getBounds()
60- let ne = bounds?getNorthEast()
61- let sw = bounds?getSouthWest()
50+ member __.GetBounds () : Coordinates.LatLngBounds option =
51+ if isNull mapRef then
52+ None
53+ else
54+ Some( mapRef?getBounds() |> unbox)
6255
63- { NE = Coordinates.newPos ( ne?lat() |> unbox) ( ne?lng() |> unbox)
64- SW = Coordinates.newPos ( sw?lat() |> unbox) ( sw?lng() |> unbox) }
56+ member __.GetZoom () : int option =
57+ if isNull mapRef then
58+ None
59+ else
60+ Some( mapRef?getZoom() |> unbox)
6561
66- member __.GetZoom () : int =
67- mapRef?getZoom() |> unbox
6862
69- member __.GetCenter () : Coordinates.Position =
70- mapRef?getCenter() |> unbox
71-
72- member __.FitBounds ( bounds : U2 < Coordinates.LatLngBounds , Coordinates.Bounds >, ? padding : float ) : unit =
73- mapRef?fitBounds( bounds, padding)
63+ member __.GetCenter () : Coordinates.LatLng option =
64+ if isNull mapRef then
65+ None
66+ else
67+ Some( mapRef?getCenter() |> unbox)
68+
69+ member __.FitBounds ( bounds : Coordinates.LatLngBounds , ? padding : float ) : unit =
70+ if not ( isNull mapRef) then
71+ mapRef?fitBounds( bounds, padding) |> ignore
7472
7573module Props =
7674
@@ -100,7 +98,7 @@ module Props =
10098 | Title of string
10199 | Icon of string
102100 | OnClick of ( unit -> unit )
103- | Position of Coordinates.Position
101+ | Position of Coordinates.LatLng
104102 interface IMarkerProperties
105103
106104 type IMarkerClustererProperties =
@@ -124,14 +122,14 @@ module Props =
124122
125123 [<RequireQualifiedAccess>]
126124 type MapProperties =
127- | SetRef of ( obj -> unit )
125+ | OnMapMounted of ( obj -> unit )
128126 | ApiKey of string
129127 | DefaultZoom of int
130128 | SearchBoxText of string
131129 | ShowSearchBox of bool
132130 | ShowTrafficLayer of bool
133- | DefaultCenter of Coordinates.Position
134- | Center of Coordinates.Position
131+ | DefaultCenter of Coordinates.LatLng
132+ | Center of Coordinates.LatLng
135133 | OnCenterChanged of ( unit -> unit )
136134 | OnPlacesChanged of ( Places.Place [] -> unit )
137135 | OnZoomChanged of ( unit -> unit )
0 commit comments