Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As pointed out in a comment on the bug report and on the API documentation, the <code>response</code> object in the callback is not pure JSON. In order to get a JSON object, I needed to create one myself like below:</p> <pre><code>//assume status is ok var bestResult = getBestResultFromJSON(results); var bounds = {'northeast' : {'lat' : 0, 'lng' : 0}, 'southwest' : {'lat' : 0, 'lng' : 0}}; var location = {'lat' : 0, 'lng' : 0}; var viewport = {'northeast' : {'lat' : 0, 'lng' : 0}, 'southwest' : {'lat' : 0, 'lng' : 0}}; // bounds not always available (https://developers.google.com/maps/documentation/javascript/reference#GeocoderGeometry) if(bestResult.geometry.hasOwnProperty(bounds)) { bounds.southwest.lat = bestResult.geometry.bounds.getSouthWest().lat(); bounds.southwest.lng = bestResult.geometry.bounds.getSouthWest().lng(); bounds.northeast.lat = bestResult.geometry.bounds.getNorthEast().lat(); bounds.northeast.lng = bestResult.geometry.bounds.getNorthEast().lng(); } else { bounds = null; } viewport.southwest.lat = bestResult.geometry.viewport.getSouthWest().lat(); viewport.southwest.lng = bestResult.geometry.viewport.getSouthWest().lng(); viewport.northeast.lat = bestResult.geometry.viewport.getNorthEast().lat(); viewport.northeast.lng = bestResult.geometry.viewport.getNorthEast().lng(); location.lat = bestResult.geometry.location.lng(); location.lng = bestResult.geometry.location.lng(); var jsonResults = {'results' : [{'address_components' : bestResult.address_components, 'formatted_address': bestResult.formatted_address, 'geometry' : {'bounds' : bounds, 'location' : location, 'location_type' : bestResult.location_type, 'viewport' : viewport}, 'types' : bestResult.types}], 'status' : status}; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload