Is it possible to restrict a location query to a specific geographic region, such as a country? RRS feed

  • Question

  • I'm using the Locations API to resolve a city and iso country code to geographic coordinates. However, when using the following query,,DE

    I run into ambiguity issues, since "DE" can also be interpreted as the state code for Delaware, US.

    Is there a way to specify that this is a country code, and not a state code? I tried the following,

    but it ignores the query completely, returning coordinates for Germany itself.

    Ricky Brundritt suggested in another thread (below) using "BERLIN, GERMANY" as the query for this specific case; however, other queries are bound to suffer from the same ambiguity, and I'd rather not have to special case Germany here. (


    works okay, but I have to guarantee that my query really is a locality before I can use it. (For example, International Airport

    does not work.)


    Tuesday, July 12, 2016 7:16 PM


  • There is no built in support for limiting the results to a particular country. You can however pass in a bounding box or a point within the country as part of the query which will influence the order of the results to make them more relevant to that location. You can do this by using the userMapView or userLocation parameters: You will still see results outside of this area, but they should be ranked lower.

    The only other option is to append the country name to the URL like you are doing, but as you have found this doesn't work in all cases.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 12, 2016 7:42 PM