-
Notifications
You must be signed in to change notification settings - Fork 63
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
README not updated load() deprecated, importLibrary doesn't replace it 1-1 #837
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.@realgs Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
@realgs const addressSearchInput = document.querySelector('autocomplete')
const options = {
componentRestrictions: { country: 'ca' },
fields: ['formatted_address', 'address_components'],
}
// make a new loader here. NOTE there are no libraries here anymore
const loader = new Loader({
apiKey: PUBLIC_GOOGLE_MAPSAPI_KEY,
version: 'weekly'
})
// you can get anything from the places library here
const { Autocomplete, PlacesService, Place } = await loader.importLibrary('places')
//and to use one its something like this
const addressComplete = new Autocomplete(addressSearchInput , options)
addressComplete .addListener('place_changed', (place)=> console.log(place))
//repeat for other libraries
const { Map, TrafficLayer } = await loader.importLibrary('maps')
const { Marker } = await loader.importLibrary('marker') I agree that documentation needs to reflect these changes. |
I'd like to add that after const loader = new Loader(loaderOptions);
await loader.importLibrary('maps');
// you can now access everything like before:
const map = new google.maps.Map(); |
Yes, indeed. with load we were able to load multiple libraries at once without any problem but with importLibrary we could only import 1 library at a time and in next recall we get below error. Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match. Assume we need Map and Markers, what we suppose to do? |
@Schmell Getting Warning Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match. |
Relevent Issue: #809 Fix: Promise.all() instead await for every importLibrary.
|
Steps to reproduce
Code example
I'd be happy to open a pull request to improve the project once you provide me with a solution. If load is deprecated what (and how) should be used instead?
The text was updated successfully, but these errors were encountered: