Reputation: 111
I'm using the Google Maps JavaScript API v3
The following code is almost straight out of a google sample code but I'm experiencing a strange issue. results[0].geometry.location has the keys "k" and "D" instead of "lat" and "lng".
Any idea why this might be happening?
mapui.geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log(results[0]);
var lat = results[0].geometry.location['lat'];
var lng = results[0].geometry.location['lng'];
}
})
Upvotes: 1
Views: 970
Reputation: 22490
You have to use the lat()
and lng()
functions. The geometry.location
is a LatLng
class.
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
https://developers.google.com/maps/documentation/javascript/reference#GeocoderGeometry https://developers.google.com/maps/documentation/javascript/reference#LatLng
Look in __proto__
in your javascript console and you will find the available methods.
Upvotes: 4