-
Notifications
You must be signed in to change notification settings - Fork 64
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
Different instances of google-maps-api with different specified libraries causes conflicts #22
Comments
If you're setting
https://github.com/GoogleWebComponents/google-map/blob/master/google-map-directions.html#L90 |
Oh, you guys added the libraries attribute! (i just changed my bower.json entries for google-map and google-api to #master) That wasn't there last time :P Thanks for the tip! Having to maintain the same value for all libraries across google maps related elements isn't very maintainable though. Is there a DRYer implementation planned in the future? (While I can think of ways to parametrize this, so far everything's a bit roundabout) |
Yea, the current setup isn't ideal. We knew this would happen by supporting the One solution is to load remove the libraries param and always load all libraries. |
Do you think it's possible to extend core-shared-library to include the ability to get the union of all the arguments of all instances of a shared library?— On Thu, Oct 2, 2014 at 12:17 AM, Eric Bidelman [email protected]
|
What happens when you load a new component later on that requests an additional library? That'll look like a different request, core-shared-library will load the Maps API, and you'll get an error about double loading the library. |
Perhaps it could check the API being requested by the new component, and see that that specific API is already loaded. It would then perform the union of arguments, then replace the existing loaded API. Would that work?
|
This is more or less how core-shared-lib works today, but it caches an API by its full URL. The problem is that it doesn't work for an API like the Maps API that you can load additional libraries via a parameter. Component 1 loads: https://maps.googleapis.com/maps/api/js?libraries=visualization,places When component 2 loads, the maps api is already loaded and gives you the error. See http://jsbin.com/zuzata/1/edit. To be 100% honest, the console warning may just be a warning. This may all be moot. |
What I mean to say is, is it possible to get the union of visualization, places, and geometry? The console warning is not just a warning though. A more concrete example: comp1 gets from https://maps.googleapis.com/maps/api/js?libraries=places
|
(merging from #57) Due to the way the Maps API loads libraries (designed in the ancient days of ~2008) you have to load all the libraries you'll need on first load and can't load more libraries later. You also need to make sure the API is only loaded once on each page. The second problem is taken care of by To eliminate these problems, I propose we always load all four libraries whenever the Maps API is loaded and eliminate the Downsides:
Why the downsides aren't so bad:
Any possible network performance problem should be fixed at the browser/Maps API/serving infrastructure levels anyways. We shouldn't burden all the As Eric notes above, the suggestion in this thread will not work because of the temporal aspect of the problem: the only union of libraries that will include all possible libraries needed by elements that could be added to the page in the future is the set of all libraries. Might as well load all of them :) |
Somewhat related to #20.
Especially problematic with
<google-map>
, which has its own import of<google-maps-api>
with hard-codedlibraries="places"
. If on the same page you have a<google-maps-api>
withlibraries="places,geometry"
, two things happen:You have included the Google Maps API multiple times on this page. This may cause unexpected errors.
This suggests that core-shared-library treats these two as separate, which causes the google warning.For example, when trying to render a polyline from an encoded string (requires the geometry library) onto a
<google-map map="{{gmap}}">
, gmap is not considered by the geometry library as type Map.However, a map created manually without the
<google-map>
(and therefore doesn't use its own<google-maps-api>
) works just fine.If I change the
google-maps-api.html
default value forlibraries
to"places,geometry
", the geometry library works properly when used withgoogle-map
.The text was updated successfully, but these errors were encountered: