Google.maps.Geocoder.geocode () Frequently asked geometry names .location lat / lng change

I have an application and I use the Google Javascript geocoding API to get lat / lng for the address.

The code looks something like

geocoder = new google.maps.Geocoder() geocoder.geocode({ 'address': query }, function(results, status) { addresses = {}; $.each(results, function(index, value){ addresses[index] = {"lat":value.geometry.location.$a,"lng":value.geometry.location.ab} }) }); 

Everything is fine and dandy, but the fact is that the property names of the location object change periodically. Every time they change, my site breaks.

Twice I had to change my code to make changes to the lat / lng property variable names in google geolocation api. Originally it was Ha, I, then I had to switch to I, Za, and now its $ a, ab. I do not see any user-friendly logic for these changes.

Does anyone know why these property names change, and / or what strategy can I use to get lat / lng, avoiding the problems caused by these property name changes?

+44
google-maps geolocation google-maps-api-3
Nov 21 '12 at 17:49
source share
1 answer

Use documented properties , they will not change

geometry.location is a google.maps.LatLng object , documented methods:

 lat() number Returns the latitude in degrees. lng() number Returns the longitude in degrees. 
+91
Nov 21 '12 at 18:13
source share



All Articles