Mickey P Mickey P - 3 days ago 6
Ajax Question

How can I prioritize search country in Bing Maps Ajax

In current realization I just add country to query, but this logic is incorrect.

$.ajax({
url: 'https://dev.virtualearth.net/REST/v1/Locations/'
+ searchString + ' ' + currentCountry + '?c=' + currentCulture + ...,
dataType: 'script'
});


But if I try to search city out of currentCountry, I will find currentCountry, but not searchString .

Example: searchString = Boston, currentCountry = Australia


Second approach - remove currentCountry from query at all, but it will cause another bug.
I will not find less famous place in currentCountry

Example: searchString = Moscow, currentCountry = USA.


Result of this query will be - Moscow, Russia and not Moscow, Washington, D.C.

Is there some ability to specify search country?
First try of search will be in currentCountry, if it fails, then second will be in all World.

Answer

According to Find a Location by Address you could get the latitude and longitude coordinates based on a set of address values for specific countries.

Example:

The query:

http://dev.virtualearth.net/REST/v1/Locations/US/Moscow?o=xml&key=BingMapsKey

Note: A structured URL specifies the location data for the country (US in this example) as part of the URL path.

will return locations for Moscow situated in United States.

Comments