Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

This element does not work on the same page as a google-map element #15

Closed
rbjarnason opened this issue Sep 12, 2015 · 13 comments
Closed
Labels

Comments

@rbjarnason
Copy link
Contributor

I get errors like:
Uncaught TypeError: m[md].maps.Load is not a function
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

Any hints how best to fix?

@rbjarnason
Copy link
Contributor Author

@rbjarnason
Copy link
Contributor Author

At the Polymer Code Labs there was suspicion that this problem originates in the iron-jsonp-library, causing the Google Maps API to be loaded twice.

@rbjarnason
Copy link
Contributor Author

@justinfagnani @garlicnation Any pointers for me, if I start looking at the issue myself?

@addyosmani
Copy link
Member

Do you have a code sample that reproduces the Uncaught TypeError: m[md].maps.Load is not a function exception you're seeing?

@rbjarnason
Copy link
Contributor Author

Here is a link that reproduces the error live:
http://www.your-priorities-preview.org/#!/group/2

And here is a link to the element that can show either Google maps or Google StreetView:
https://github.com/rbjarnason/your-priorities-app/blob/master/client_app/elements/yp-idea/yp-idea-cover-media.html

@rbjarnason
Copy link
Contributor Author

Seems to be showing "You have included the Google Maps API multiple times on this page." all the time now but the "Uncaught TypeError: m[md].maps.Load is not a function" does show up sometimes, we looked at this at the Polymer Code Labs in Amsterdam and looked like a timing issue what error would show...

@addyosmani addyosmani added the bug label Sep 29, 2015
@garlicnation
Copy link

The problem is the "libraries" field of the google-maps-api element. google-streetview-pano defaults to "places", and google-map defaults to "". This causes iron-jsonp-library to treat google-map as a separate library and causes the error.

The "libraries" object may need to be a singleton, and can only be configured once per application. Additionally, the google api wrapper should refuse to load any library a second time.

@rbjarnason
Copy link
Contributor Author

I tried setting google-maps libraries to default to 'places' to test this - and works better and I can see maps and streetview on the same page. But there is still an issue, if I move between iron-pages with streetview being redrawn I get the error in this screenshot and streetviews stop showing. Maybe I should file that separately or is this connected? Seem to be that you can't load GoogleStreetViewPano elements twice in the same iron-pages "session".

streetviewpanobug

@ebidel
Copy link
Contributor

ebidel commented Sep 29, 2015

That's right. A recent change of google-map changed the default libraries="places" to libraries="" because most people will only be using google-map by itself. There was no reason to load the places library for all users when they never needed it.

@garlicnation the problem with not loading the library twice is that iron-jsonp-library doesn't know what URLs you give it. So using a different maps component that requires different set of libraries will cause this error. This is a fundamental flaw with how the Maps API loads modules. @brendankenny explained it to me once, and I cried. Our solution was to require users to specify the same libraries value on all maps components that are loaded. Do you think there's a cleaner way with iron-meta or something?

@rbjarnason that error looks unrelated. Can you file a separate issue?

@ebidel
Copy link
Contributor

ebidel commented Sep 29, 2015

Added a note to the docs: 2b11357

@rbjarnason
Copy link
Contributor Author

Thanks @ebidel I have researched this a bit more and filed a new issue here #16 for the failure on second use with iron-pages.

@rbjarnason
Copy link
Contributor Author

As we now have a workaround I won't spend more time on this and will leave it up to you guys to find a solution for this in due time. Thanks for your help! :)

@ebidel
Copy link
Contributor

ebidel commented Sep 30, 2015

Thanks. I'm going to close this issue then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants