I found out, while using Google Maps API, the results change from time to time. By change I mean the response object. Basically I'm querying Google Maps to get a list of places based on user input (also using jQueryUI auto complete). I'm trying to correctly fetch the coordinates which get returned from Google Maps API but the properties containing the exact|approximate coordinates seem to change from time to time.
For example: in earlier days I was able to get coordinates like item.geocode.geometry.location.Ya
and item.geocode.geometry.location.Za
. Then my search form broke because Google changed it to item.geometry.location.mb
and item.geometry.location.nb
.
Any suggestions on how to implement this the correct, and stable way?
All Maps Embed API requests are available at no charge with unlimited usage.
When using Google Place API, the result per a query is limited to 20.
Never use undocumented properties of a Maps API object like the ones you found. Those will change wildly whenever the Maps API is revised.
Instead, use only documented methods and properties.
Your item.geocode.geometry.location
is a LatLng
, so you can call its .lat()
and .lng()
methods:
var location = item.geocode.geometry.location;
var lat = location.lat();
var lng = location.lng();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With