export map & maps objects from 'google-map-react'
Once again, thanks a lot for the amazing efforts and helping the community.
We've been using this library in our project for more than a year. Since we have more than 10000 markers. we paint the markers externally using map & maps objects via canvas, and assign them the events. (Since adding these markers as react components slows down the performance for large amount of markers).
And the main problem, to have access to map and maps objects, we're having to store these in global states. I see that maps is available in window.google.maps, but not map. Would have been great if both map & maps were accessible in a global context - either from window.google.x, or as imports from the library, instead of users having to extract the objects from onGoogleApiLoaded and spread globally
+1 on this. I'm trying to use google-map-react with use-places-autocomplete. use-places-autocomplete takes a Google Maps object. It makes sense for this library to do that as well, so we can choose to load the API in whichever way we'd like.
Set a state in apiLoaded function and pass the map to the autocomplete such as
onGoogleApiLoaded={({ map, maps }) => handleApiLoaded(map, maps)}
const handleApiLoaded = (map, maps) => {
setConfig({
mapApiLoaded: true,
mapInstance: map,
mapApi: maps,
})
}
...
... Later in render
...
{config.mapApiLoaded && (
<AutoComplete
map={config.mapInstance}
api={config.mapApi}
/>
)}
``