I was trying to use the Google Maps Reverse Geocoding (translating a location on the map into a human-readable address) via the JavaScript API, and I wanted to filter the results to get only the street addresses.
As I saw in the docs, there is a result_type
optional parameter for this request, but when specifying it, I get the following error:
InvalidValueError: unknown property result_type
I include the API by loading this script: https://maps.googleapis.com/maps/api/js?key=MY_API_KEY
And here is the code I use for reverse geocoding:
geocoder = new google.maps.Geocoder();
geocoder.geocode(
{
location: {lat: parseFloat(lat), lng: parseFloat(lng)},
result_type: 'street_address'
},
function(results, status) {
if (status === 'OK') {
console.log(results);
}
}
);
A small playground fiddle: https://jsfiddle.net/scebotari66/30nshzb6/.
However, when I try this via a direct HTTP request (https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&key=MY_API_KEY), everything works as expected.
InvalidValueError: unknown property types
– Dashtikavir