Kazekage Gaara
Kazekage Gaara

Reputation: 15052

Google Places Nearby Search requests returns different values intermittently

I've been using Google Places API for Nearby Search Requests . I noticed one particular thing. Here's a block from one sample output.

geometry: Object
location: P
ob: 28.579
pb: 77.36831899999993

Do you notice the parameters ob and pb. I've noticed them to change quite regularly. A few weeks back they were jb and kb. Then they became lb and mb. Now when I'm trying them out, they are ob and pb.

Although I've found a way around to use these values without referring them by their keys, but I'm still curious as to whether these key names hold any significance and why are they changing so frequently?

Upvotes: 1

Views: 1165

Answers (3)

ben__day
ben__day

Reputation: 13

I had a similar issue when trying to parse the JSON result from the places autosuggest drop down.

To avoid this problem, you can call the lat and lng methods on the location object rather than attempt to use the fields by name.

Something like:

var longitude = place.geometry.location.lng();
var latitude = place.geometry.location.lat();

Though it worth sharing.

Upvotes: 1

Tibos
Tibos

Reputation: 27823

They are the result of a minification process (which takes variables, function and property names and replaces them consistently in order to reduce the size of your scripts). Whenever something changes in the minification process (minifier code changes, javascript code changes, etc) there is a chance that the replaced name for a certain property is different than it was before.

Upvotes: 2

George I.
George I.

Reputation: 582

As a general rule for Google Maps API, accessing data (like coordinates for example) is not done accessing the JavaScript objects directly, but querying the response. This is a nearby search example from Google: https://developers.google.com/maps/documentation/javascript/examples/place-search You should check how is it accessed in this snippet:

function createMarker(place) {
  var placeLoc = place.geometry.location;
  var marker = new google.maps.Marker({
    map: map,
    position: place.geometry.location
  });
}

Upvotes: 2

Related Questions