fable-compiler / fable.reactgooglemaps Goto Github PK
View Code? Open in Web Editor NEWFable bindings and helpers for react-google-map
License: Apache License 2.0
Fable bindings and helpers for react-google-map
License: Apache License 2.0
Hi @forki, I can't remember it myself but something tells me you don't need to add @babel/plugin-proposal-class-properties
anymore.
Do you still have it in your project with the latest code?
If not we should update the readme.
@nojaf any ideas?
Hi there,
I am trying to incorporate Fable.ReactGoogleMaps into my Safe Simplifed stack (Felize). I could show the map and add markers. But I could not do the following
I think the problem is from Google Map js script is dynamically loaded which cause Fable compilation error. I fix that by follow original readme from Fable.Import google map which is:
externals: {
'google.maps': 'window.google.maps'
},
Now the error is gone and I could sometime call other Google API service. But most of the time it show error that
can't access property "maps", window.google is undefined
I guess that my code trying to invoke actual google map library but the library is not loaded. Are there any ways to wait until the Google Map js library finished loading before I call service api. I did try to call function in OnIdle as follow:
let route() =
printfn "route GetBounds %A" (mapRef.GetBounds())
//()
if (mapRef.GetBounds().IsSome) then
let directionService = GoogleMaps.maps.DirectionsService.Create()
let directionRenderer = GoogleMaps.maps.DirectionsRenderer.Create()
let map:GoogleMaps.Map option = Some (GoogleMaps.maps :?> GoogleMaps.Map)
directionRenderer.setMap(map)
let origin = GoogleMaps.maps.LatLng.Create(10.11111, 10.22222)
let destination = GoogleMaps.maps.LatLng.Create(11.11111, 11.22222)
let req:GoogleMaps.DirectionsRequest =
{ new GoogleMaps.DirectionsRequest with
member x.avoidFerries with get() = None and set v = ()
member x.avoidHighways with get() = None and set v = ()
member x.avoidTolls with get() = None and set v = ()
member x.destination with get() = Some !^destination and set v = ()
member x.durationInTraffic with get() = None and set v = ()
member x.drivingOptions with get() = None and set v = ()
member x.optimizeWaypoints with get() = None and set v = ()
member x.origin with get() = Some !^original and set v = ()
member x.provideRouteAlternatives with get() = None and set v = ()
member x.region with get() = None and set v = ()
member x.transitOptions with get() = None and set v = ()
member x.travelMode with get() = Some ("DRIVING" :> obj) and set v = ()
member x.unitSystem with get() = None and set v = ()
member x.waypoints with get() = None and set v = () }
directionService.route(req, fun resp status -> printfn "route %A" resp.routes.Count;
directionRenderer.setDirections(resp))
else
printfn "no bounds"
()
let onIdle() =
if mapRef.GetBounds().IsSome then
route ()
else
printfn "no bounds
let map' center markers =
let googleMapApiKey = Config.variable "GOOGLE_MAP_API_KEY"
googleMap [
MapProperties.ApiKey googleMapApiKey
MapProperties.MapLoadingContainer "maploadercontainer"
MapProperties.MapContainer "mapcontainer"
MapProperties.DefaultZoom 12
MapProperties.DefaultCenter !^ center
MapProperties.Center !^ center
MapProperties.Markers markers
MapProperties.OnMapMounted onMapMounted
MapProperties.OnIdle onIdle
]
The direction count return correctly. The problem is that error happens sometimes to time. if I comment and uncomment the code several times, it will run.
Any help will be really appreciated. I am sorry to post questions here. (not sure that it is an issue or not) But I try to post this question in f# slack but still got no complete answer yet. So I decide to ask here where the library created.
Thank you very much,
TW
The latest version of the Fable.ReactGoogleMaps project (0.8.2) seems to have a totally different API to the "old" version that's referenced in the readme. Have I done something wrong or do the docs just need updating?
Hi, looking for an example on how to use the MapOptions
object of the library. An example would be much appreciated. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.