data.geometry.location

4,111 views
Skip to first unread message

Martin

unread,
Mar 30, 2010, 6:21:03 PM3/30/10
to Google Maps JavaScript API v3
Hi,
I tried to find if somebody else had this "issue" but I didn't find
anything. It seems odd to me that I would be the only one, so I may be
doing something wrong.

My model in db has .city_lat & .city_lon attributes. I extract the
values for those from Geocoder's result, from .geometry.location. The
issue I'm facing is that the location object returns latitude and
longitude objects under names that keep changing.

For example, some time ago, I had in my code:
$('#city_lat').val(_data.geometry.location.a)
$('#city_lon').val(_data.geometry.location.b)

now, I have to have:
$('#city_lat').val(_data.geometry.location.b)
$('#city_lon').val(_data.geometry.location.c)

.location.a was changed into .location.b for latitude, similarly for
longitude.

Why is that? But more importantly, how do I code it so I don't have to
continuously check for google's changes of the longitude and latitude
objects names?

thanks,
martin

Chad Killingsworth

unread,
Mar 30, 2010, 8:15:01 PM3/30/10
to Google Maps JavaScript API v3
Any properties not specifically referenced in the documentation are
considered internal and not meant to be directly used. They can and do
change.

If you'll take a look at the LatLng object documentation:
http://code.google.com/apis/maps/documentation/v3/reference.html#LatLng
- you can use the lat() and lng() methods to retrieve the values.

$('#city_lat').val(_data.geometry.location.lat())
$('#city_lon').val(_data.geometry.location.lng())

Chad Killingsworth

Martin

unread,
Mar 30, 2010, 8:54:40 PM3/30/10
to Google Maps JavaScript API v3
And that takes care of that! Thank you Chad,
martin

On Mar 30, 7:15 pm, Chad Killingsworth

Reply all
Reply to author
Forward
0 new messages