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-map-marker does not work when latitude and longitude are provided by AngularJS #49

Closed
rightfold opened this issue Sep 3, 2014 · 3 comments

Comments

@rightfold
Copy link

Given the following example:

<google-map fitToMarkers>
    <google-map-marker latitude="{{ selectedAddress.coordinates.latitude }}"
                       longitude="{{ selectedAddress.coordinates.longitude }}">
    </google-map-marker>
</google-map>

where selectedAddress.coordinates is {latitude: 20, longitude: 20} breaks with an error in Google Maps API because this.latitude and this.longitude in updatePosition are strings, not numbers. It'd be very useful if the assumption that these values are numbers were not there.

This seems to happen because setAttribute converts its second argument to a string, and Polymer's misfeature of guessing the expected type and automatically converting does not work when an attribute is set with setAttribute.

@rightfold rightfold changed the title google-map-marker does not work when latitude and longitude are provided by Angular.js google-map-marker does not work when latitude and longitude are provided by AngularJS Sep 3, 2014
@ebidel
Copy link
Contributor

ebidel commented Sep 3, 2014

We can cast those values to ensure they're floats.

Where are you getting selectedAddress.coordinates from? If they're numbers
it stuff work fine. Did you mean they're strings?

The maps api expects float numbers, not strings (
https://developers.google.com/maps/documentation/javascript/3.exp/reference#LatLngLiteral
).
On Sep 3, 2014 7:01 AM, "Radek Slupik" notifications@github.com wrote:

Given the following example:

Where selectedAddress.coordinates is {latitude: 20, longitude: 20} breaks
with an error in Google Maps API because this.latitude and this.longitude
in updatePosition
https://github.com/GoogleWebComponents/google-map/blob/master/google-map.html#L113
are strings, not numbers. It'd be very useful if the assumption that these
values are numbers were not there.


Reply to this email directly or view it on GitHub
#49.

@rightfold
Copy link
Author

They are numbers in my data (selectedAddress.coordinates is {latitude: 20, longitude: 20}), but AngularJS calls setAttribute and setAttribute casts the value to a string.

@ebidel
Copy link
Contributor

ebidel commented Sep 3, 2014

I'll put in a check, but when I test .setAttribute('latitude', 37.879) or .setAttribute('latitude', '37.879') directly on the map element in the console, there are no errors.

Have you seen https://github.com/matjaz/angu-poly? It's a lib that makes Angular understand two-way bindings on attributes.

@ebidel ebidel closed this as completed in 1e318a1 Sep 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants