Mickey P Mickey P - 1 year ago 79
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.

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 Source

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.


The query:


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download