Luis Franco
Luis Franco

Reputation: 11

Getting country with result_type=country doesn’t work

I’m using the Google Maps Geolocation API to obtain a country code giving the coordinates. But for some coordinates the filter I use in result_type doesn’t get the country code

Examples: For GB - United Kingdom

https://maps.googleapis.com/maps/api/geocode/json?latlng=51.507351,-0.127758&result_type=country&key=[KEY] -> doesn’t return any result

but if I use the result_type=country|political https://maps.googleapis.com/maps/api/geocode/json?latlng=51.507351,-0.127758&result_type=country|political&key=[KEY] -> it returns OK

For DE - Germany" https://maps.googleapis.com/maps/api/geocode/json?latlng=52.520007,13.404954&result_type=country&key=[KEY] - > just using the result_type=country works OK ]

Calling the API with no filter on result_type works but I have to iterate for every address

Did anyone have similar behavior?

Upvotes: 1

Views: 572

Answers (1)

Cole Huffman
Cole Huffman

Reputation: 300

By removing your specified parameter, the Geocoding web service will return your reverse geocoded result by default (human readable address).

This is the default functionality of the web service, and if you want a different result you must set your parameters as you did in the result_type field of the request.

You can read up more on how this works here.

Upvotes: 1

Related Questions