GoogleWebComponents / google-apis

Web components for loading Google's JavaScript Libraries
https://elements.polymer-project.org/elements/google-apis
Other
87 stars 64 forks source link

Cannot load Google Maps API libraries #69

Closed gaurav21r closed 8 years ago

gaurav21r commented 8 years ago

When trying to access the geometry API via $element.map.geometry is undefined.

According to the API Docs, this can happen when the libraries parameter does not have geometry. https://developers.google.com/maps/documentation/javascript/libraries

Although this https://github.com/GoogleWebComponents/google-apis/blob/master/google-maps-api.html#L115 seems to include all Libraries.

ebidel commented 8 years ago

I believe the namespace would be google.map.geometry. The APIs aren't hung off the element. The Maps API still puts them on the global scope. Alternatively, you can access the API on this element as <element>.api.geometry

gaurav21r commented 8 years ago

@ebidel Thank you for your prompt response!

I tried the namespace in my project but geometry was not defined. But I tried it in the Polymer catalog example and it did come! I will try to recreate my scenario here somehow.

The <element>.api you speak of is actually the <google-maps-api> element and not the <google-map>. Understandable since it is a static object from the API and instance methods / props would be in <google-maps-api>. But it isn't very apparent on first look. Can we improve the documentation somehow?

ebidel commented 8 years ago

Well technically it's not meant to be accessed by google-map users. It's part of the element's shadow DOM. I'd recommend using the global namespace in your code