Skip to content
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

Google Maps script included multiple times #81

Open
cairocoder01 opened this issue Jun 14, 2024 · 0 comments
Open

Google Maps script included multiple times #81

cairocoder01 opened this issue Jun 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cairocoder01
Copy link
Collaborator

When showing a dt-location-map field that has multiple geocoded locations as the initial value, console errors are thrown:

You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.

This is likely because the googleGeocodingService is initialize in the dt-location-map-item, so each location is trying to include the script again. It should probably be included in the parent component and passed down somehow.

There still needs to be some handling in case there are then multiple location components on the page that are pre-populated. The service tries to detect if it's already loaded in the constructor by looking for window.google?.maps?.places?.AutocompleteService, but the script probably isn't loaded by the time the next constructor is called. It would probably be better to check the document for the existence of another script tag with the same source file.

@cairocoder01 cairocoder01 added the bug Something isn't working label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant