-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is deprecating load() and similar methods a good idea? #811
Comments
If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.@bjornharvold Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
const loader = new Loader({apiKey: '', libraries: ['maps', 'drawing']}); |
The constructor and Instead of const loader = new Loader({apiKey: '...', libraries: ['places']});
await loader.load(); you can now write const loader = new Loader({apiKey: '...', libraries: ['places']});
await loader.importLibrary('maps'); for exactly the same behaviour. In both cases - once the promise returned by In addition to that, the So when different components in your application need access to different maps-libraries, e.g. Map and PlacesService, you can now do it like this: // somewhere globally (note we're not specifying any libraries here)
const loader = new Loader({apiKey: '...'});
// ...in the component that renders the map
const {Map} = await loader.importLibrary('maps');
const map = new Map(mapDivEl, {center, zoom});
// ...in another component that needs the placesService
const placesLib = await loader.importLibrary('places');
const service = new placesLib.PlacesService(); This could help you save some requests for compnents that aren't actually needed everywhere in the application. |
Works |
Hi Team Google Maps!
I just came across your library and I wanted to have a closer look. Previously, we have our own Javascript loader that dynamically adds the google Maps JS script element to head and issues a loaded event in our reactive environment. The loaded event tells us we can safely create a new Map now that the google namespace is loaded and available.
In our Ngrx effect, it looks something like this:
Notice that we do not do anything else at this point. We separate loading with instantiating. The event is all we need.
When looking at your loader, your documentation says to use methods that have all been deprecated and instead do something like this:
'loader.importLibraries('maps')`
Does this make any sense?
If we are using this npm module, it's probably because we want to load the Google Maps JS SDK, I would assume 'maps' gets loaded by default and libraries are all overlays and features on top of the actual map.
I would request that we keep the load() method around and not deprecate it [unless I am missing something obvious 🤔].
Cheers,
Bjorn
The text was updated successfully, but these errors were encountered: