Skip to content

Commit be11d4d

Browse files
author
Maxime Mangel
authored
Merge pull request #102 from nojaf/google-maps
Using generated GoogleMaps types from ts2fable.
2 parents 923feb9 + da8e80b commit be11d4d

File tree

5 files changed

+86
-81
lines changed

5 files changed

+86
-81
lines changed

paket.dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ clitool dotnet-Fable
55
nuget Fable.Core
66
nuget Fable.Geojson
77
nuget Fable.Import.Browser
8+
nuget Fable.Import.GoogleMaps
89
nuget Fable.Leaflet
910

1011
group Build

paket.lock

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
STORAGE: NONE
22
NUGET
33
remote: https://www.nuget.org/api/v2
4-
dotnet-fable (2.0.1) - clitool: true
4+
dotnet-fable (2.0.2) - clitool: true
55
Dotnet.ProjInfo (>= 0.9) - restriction: >= netcoreapp2.0
66
FSharp.Compiler.Service (>= 25.0.1) - restriction: >= netcoreapp2.0
77
FSharp.Core (>= 4.5.2) - restriction: >= netcoreapp2.0
@@ -15,6 +15,9 @@ NUGET
1515
Fable.Core (>= 1.3.8) - restriction: >= netstandard1.6
1616
Fable.Import.Browser (1.3)
1717
Fable.Core (>= 1.3.17) - restriction: >= netstandard1.6
18+
Fable.Import.GoogleMaps (0.1)
19+
Fable.Core (>= 1.3.17) - restriction: >= netstandard1.6
20+
Fable.Import.Browser (>= 1.3) - restriction: >= netstandard1.6
1821
Fable.Leaflet (0.1)
1922
Fable.Core (>= 1.3.8) - restriction: >= netstandard1.6
2023
Fable.Geojson (>= 0.1) - restriction: >= netstandard1.6
@@ -30,16 +33,16 @@ NUGET
3033
System.Runtime.Loader (>= 4.0) - restriction: && (< net45) (>= netstandard2.0)
3134
System.Security.Cryptography.Algorithms (>= 4.3) - restriction: && (< net45) (>= netstandard2.0)
3235
FSharp.Core (4.5.2) - restriction: >= netstandard2.0
33-
Microsoft.NETCore.App (2.1.4) - restriction: >= netcoreapp2.0
34-
Microsoft.NETCore.DotNetHostPolicy (>= 2.1.4) - restriction: >= netcoreapp2.1
36+
Microsoft.NETCore.App (2.1.5) - restriction: >= netcoreapp2.0
37+
Microsoft.NETCore.DotNetHostPolicy (>= 2.1.5) - restriction: >= netcoreapp2.1
3538
Microsoft.NETCore.Platforms (>= 2.1.1) - restriction: >= netcoreapp2.1
3639
Microsoft.NETCore.Targets (>= 2.0) - restriction: >= netcoreapp2.1
3740
NETStandard.Library (>= 2.0.3) - restriction: >= netcoreapp2.1
38-
Microsoft.NETCore.DotNetAppHost (2.1.4) - restriction: >= netcoreapp2.1
39-
Microsoft.NETCore.DotNetHostPolicy (2.1.4) - restriction: >= netcoreapp2.1
40-
Microsoft.NETCore.DotNetHostResolver (>= 2.1.4)
41-
Microsoft.NETCore.DotNetHostResolver (2.1.4) - restriction: >= netcoreapp2.1
42-
Microsoft.NETCore.DotNetAppHost (>= 2.1.4)
41+
Microsoft.NETCore.DotNetAppHost (2.1.5) - restriction: >= netcoreapp2.1
42+
Microsoft.NETCore.DotNetHostPolicy (2.1.5) - restriction: >= netcoreapp2.1
43+
Microsoft.NETCore.DotNetHostResolver (>= 2.1.5)
44+
Microsoft.NETCore.DotNetHostResolver (2.1.5) - restriction: >= netcoreapp2.1
45+
Microsoft.NETCore.DotNetAppHost (>= 2.1.5)
4346
Microsoft.NETCore.Platforms (2.1.1) - restriction: >= netcoreapp2.0
4447
Microsoft.NETCore.Targets (2.1) - restriction: >= netcoreapp2.0
4548
Microsoft.Win32.Primitives (4.3) - restriction: >= netcoreapp2.0
@@ -207,7 +210,7 @@ NUGET
207210
System.Runtime (4.3) - restriction: >= netcoreapp2.0
208211
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.2) (< win8) (< wp8)) (&& (< monoandroid) (< net45) (>= netstandard1.2) (< netstandard1.3) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (< portable-net45+win8+wp8+wpa81)
209212
Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.2) (< win8) (< wp8)) (&& (< monoandroid) (< net45) (>= netstandard1.2) (< netstandard1.3) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (< portable-net45+win8+wp8+wpa81)
210-
System.Runtime.CompilerServices.Unsafe (4.5.1) - restriction: || (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netstandard1.1)) (&& (>= netcoreapp2.0) (< netstandard2.0)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (>= netcoreapp2.0) (>= xamarinios)) (&& (>= netcoreapp2.0) (>= xamarinmac)) (&& (>= netcoreapp2.0) (>= xamarintvos)) (&& (>= netcoreapp2.0) (>= xamarinwatchos))
213+
System.Runtime.CompilerServices.Unsafe (4.5.2) - restriction: || (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netstandard1.1)) (&& (>= netcoreapp2.0) (< netstandard2.0)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (>= netcoreapp2.0) (>= xamarinios)) (&& (>= netcoreapp2.0) (>= xamarinmac)) (&& (>= netcoreapp2.0) (>= xamarintvos)) (&& (>= netcoreapp2.0) (>= xamarinwatchos))
211214
System.Runtime.Extensions (4.3) - restriction: >= netcoreapp2.0
212215
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (< portable-net45+win8+wp8+wpa81)
213216
Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (< portable-net45+win8+wp8+wpa81)
@@ -271,7 +274,7 @@ NUGET
271274
System.Runtime (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
272275
System.Threading (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
273276
System.Threading.Tasks (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
274-
System.Security.Principal.Windows (4.5) - restriction: >= netcoreapp2.0
277+
System.Security.Principal.Windows (4.5.1) - restriction: >= netcoreapp2.0
275278
Microsoft.NETCore.Platforms (>= 2.0) - restriction: >= netcoreapp2.0
276279
System.Text.Encoding (4.3) - restriction: >= netcoreapp2.0
277280
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (< portable-net45+win8+wp8+wpa81)
@@ -299,12 +302,67 @@ GROUP Build
299302
RESTRICTION: == net46
300303
NUGET
301304
remote: https://www.nuget.org/api/v2
302-
FAKE (4.63.2)
303-
FSharp.Core (4.2.3) - content: none, redirects: force
304-
Octokit (0.28)
305+
FAKE (5.3)
306+
Fake.Core.Context (5.7.2)
307+
FSharp.Core (>= 4.3.4)
308+
Fake.Core.Environment (5.7.2)
309+
FSharp.Core (>= 4.3.4)
310+
Fake.Core.FakeVar (5.7.2)
311+
Fake.Core.Context (>= 5.7.2)
312+
FSharp.Core (>= 4.3.4)
313+
Fake.Core.Process (5.7.2)
314+
Fake.Core.Environment (>= 5.7.2)
315+
Fake.Core.FakeVar (>= 5.7.2)
316+
Fake.Core.String (>= 5.7.2)
317+
Fake.Core.Trace (>= 5.7.2)
318+
Fake.IO.FileSystem (>= 5.7.2)
319+
FSharp.Core (>= 4.3.4)
320+
System.Diagnostics.Process (>= 4.3)
321+
Fake.Core.ReleaseNotes (5.7.2)
322+
Fake.Core.SemVer (>= 5.7.2)
323+
Fake.Core.String (>= 5.7.2)
324+
FSharp.Core (>= 4.3.4)
325+
Fake.Core.SemVer (5.7.2)
326+
FSharp.Core (>= 4.3.4)
327+
System.Runtime.Numerics (>= 4.3)
328+
Fake.Core.String (5.7.2)
329+
FSharp.Core (>= 4.3.4)
330+
Fake.Core.Trace (5.7.2)
331+
Fake.Core.Environment (>= 5.7.2)
332+
Fake.Core.FakeVar (>= 5.7.2)
333+
FSharp.Core (>= 4.3.4)
334+
Fake.Core.UserInput (5.7.2)
335+
FSharp.Core (>= 4.3.4)
336+
Fake.DotNet.Cli (5.7.2)
337+
Fake.IO.FileSystem (5.7.2)
338+
Fake.Core.String (>= 5.7.2)
339+
FSharp.Core (>= 4.3.4)
340+
System.Diagnostics.FileVersionInfo (>= 4.3)
341+
System.IO.FileSystem.Watcher (>= 4.3)
342+
Fake.Tools.Git (5.7.2)
343+
Fake.Core.Environment (>= 5.7.2)
344+
Fake.Core.Process (>= 5.7.2)
345+
Fake.Core.SemVer (>= 5.7.2)
346+
Fake.Core.String (>= 5.7.2)
347+
Fake.Core.Trace (>= 5.7.2)
348+
Fake.IO.FileSystem (>= 5.7.2)
349+
FSharp.Core (>= 4.3.4)
350+
FSharp.Core (4.5.2) - content: none, redirects: force
351+
Octokit (0.32)
352+
System.Diagnostics.FileVersionInfo (4.3)
353+
System.Diagnostics.Process (4.3)
354+
System.IO.FileSystem.Watcher (4.3)
355+
System.Runtime.Numerics (4.3)
305356
GITHUB
306357
remote: fsharp/FAKE
307-
modules/Octokit/Octokit.fsx (0341a2e614eb2a7f34607cec914eb0ed83ce9add)
358+
modules/Octokit/Octokit.fsx (16fa0088b1cce2f04a126e2febeddd2b8b6e6048)
308359
Octokit (>= 0.20)
309360
remote: fable-compiler/fake-helpers
310-
Fable.FakeHelpers.fs (ac8d3f6677366c381350023977dbe91adc9aa8a0)
361+
Fable.FakeHelpers.fs (1b26f2cd88aab4895b1d330edf30f3852ea81652)
362+
Fake.Core.Process
363+
Fake.Core.ReleaseNotes
364+
Fake.Core.String
365+
Fake.Core.UserInput
366+
Fake.DotNet.Cli
367+
Fake.IO.FileSystem
368+
Fake.Tools.Git

src/Fable.ReactGoogleMaps/Fable.Helpers.ReactGoogleMaps.fs

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,7 @@ module Fable.Helpers.ReactGoogleMaps
33
open Fable.Core
44
open Fable.Import
55
open Fable.Core.JsInterop
6-
7-
module Coordinates =
8-
9-
/// GoogleMaps Position
10-
/// see https://developers.google.com/maps/documentation/javascript/reference/coordinates
11-
type LatLng =
12-
abstract member lat: unit -> float
13-
abstract member lng: unit -> float
14-
15-
let newLatLng (lat: float, lng: float) : LatLng =
16-
let pos = obj()
17-
pos?lat <- lat
18-
pos?lng <- lng
19-
pos |> unbox
20-
21-
22-
// https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngBounds
23-
24-
type LatLngBounds =
25-
abstract member extend : LatLngBounds -> LatLngBounds
26-
abstract member extend : LatLng -> LatLngBounds
27-
abstract member getSouthWest : unit -> LatLng
28-
abstract member getNorthEast : unit -> LatLng
29-
30-
31-
let newLatLngBounds (sw: LatLng, ne: LatLng) : LatLng =
32-
let bounds = obj()
33-
bounds?sw <- sw
34-
bounds?ne <- ne
35-
bounds |> unbox
36-
37-
38-
let emptyLatLngBounds () : LatLngBounds =
39-
let bounds = obj()
40-
bounds |> unbox
41-
42-
let getBoundsFromLatLngs(positions:LatLng seq) : LatLngBounds =
43-
let mutable b = emptyLatLngBounds()
44-
for pos in positions do
45-
b <- b.extend pos
46-
b
47-
48-
module Places =
49-
50-
type Geometry = {
51-
location: Coordinates.LatLng
52-
}
53-
54-
type Place = {
55-
geometry: Geometry
56-
}
57-
6+
open Fable.Import.GoogleMaps
587

598
module R = Fable.Helpers.React
609

@@ -63,7 +12,7 @@ type RCom = React.ComponentClass<obj>
6312
type MapRef(mapRef) =
6413

6514
/// Get the current bounds of the Map
66-
member __.GetBounds() : Coordinates.LatLngBounds option =
15+
member __.GetBounds() : LatLngBounds option =
6716
if isNull mapRef then
6817
None
6918
else
@@ -76,13 +25,13 @@ type MapRef(mapRef) =
7625
Some(mapRef?getZoom() |> unbox)
7726

7827

79-
member __.GetCenter() : Coordinates.LatLng option =
28+
member __.GetCenter() : LatLng option =
8029
if isNull mapRef then
8130
None
8231
else
8332
Some(mapRef?getCenter() |> unbox)
8433

85-
member __.FitBounds(bounds: Coordinates.LatLngBounds, ?padding: float) : unit =
34+
member __.FitBounds(bounds: LatLngBounds, ?padding: float) : unit =
8635
if not(isNull mapRef) then
8736
mapRef?fitBounds(bounds, padding) |> ignore
8837

@@ -114,7 +63,7 @@ module Props =
11463
| Title of string
11564
| Icon of string
11665
| OnClick of (unit -> unit)
117-
| Position of Coordinates.LatLng
66+
| Position of U2<LatLng, LatLngLiteral>
11867
interface IMarkerProperties
11968

12069
type IMarkerClustererProperties =
@@ -132,10 +81,6 @@ module Props =
13281
type IMapProperties =
13382
interface end
13483

135-
// https://developers.google.com/maps/documentation/javascript/events#EventArguments
136-
type GoogleMapsMouseEvent =
137-
{ latLng: Coordinates.LatLng }
138-
13984
[<RequireQualifiedAccess>]
14085
type MapProperties =
14186
| OnMapMounted of (obj -> unit)
@@ -144,13 +89,13 @@ module Props =
14489
| SearchBoxText of string
14590
| ShowSearchBox of bool
14691
| ShowTrafficLayer of bool
147-
| DefaultCenter of Coordinates.LatLng
148-
| Center of Coordinates.LatLng
92+
| DefaultCenter of U2<LatLng,LatLngLiteral>
93+
| Center of U2<LatLng, LatLngLiteral>
14994
| OnCenterChanged of (unit -> unit)
150-
| OnPlacesChanged of (Places.Place [] -> unit)
95+
| OnPlacesChanged of (Place [] -> unit)
15196
| OnZoomChanged of (unit -> unit)
15297
| OnIdle of (unit -> unit)
153-
| OnClick of (GoogleMapsMouseEvent -> unit)
98+
| OnClick of (MouseEvent -> unit)
15499
| Markers of React.ReactElement seq
155100
| [<CompiledName("Markers")>] Clusterer of React.ReactElement
156101
| MapLoadingContainer of string
@@ -191,4 +136,4 @@ let googleMap (props:Props.IMapProperties list) : React.ReactElement =
191136
R.from GoogleMapComponent (keyValueList CaseRules.LowerFirst props) []
192137

193138

194-
let getPosition (options: obj) : Fable.Import.JS.Promise<Fable.Import.Browser.Position> = importMember "./location.js"
139+
let getPosition (options: obj) : Fable.Import.JS.Promise<Fable.Import.Browser.Position> = importMember "./location.js"

src/Fable.ReactGoogleMaps/Fable.ReactGoogleMaps.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<Version>0.4.3</Version>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
FSharp.Core
22
Fable.Core
33
Fable.Import.Browser
4+
Fable.Import.GoogleMaps

0 commit comments

Comments
 (0)