简体   繁体   中英

Display all business locations from Data Source URL in Bing Maps

For a store locator, let's say I'm using Bing's example data source url: https://spatial.virtualearth.net/REST/v1/data/515d38d4d4e348d9a61c615f59704174/CoffeeShops/CoffeeShop

In Bing's example , the user has to search in order for the store locations to populate, which is fine if you're Starbuck's and you have thousands of locations, but business requirements are that we need to show all of our 10-15 locations on a map of the full United States.

It looks like there are plenty of modules for searching and finding all locations within a box, or finding nearby locations within a specified radius, clustering a lot of locations within the viewport, but I can't for the life of me figure out how to simply load all Contoso Coffee locations from the data source URL.

The closest answer that I could find is this: Zoom to show all locations in bing maps The chosen answer:

var locations = CurrentItems.Select(model => model.Location);
map.SetView(LocationRect.CreateLocationRect(locations));

But I could not get it to work. I've also tried:

var queryOptions = {
queryUrl: dataSourceUrl,
spatialFilter: {
    spatialFilterType: 'nearby',
    location: location,
    radius: 1000
},
};

Microsoft.Maps.SpatialDataService.QueryAPIManager.search(queryOptions, map, function (results) {
...
});

This doesn't work because 1000 is the max radius and some of the my locations would be outside of it.

Other than that, I've been trying to find the exact module that reproduces vaguely what I'm looking for, but they keep coming up as dead ends.

I'm sure it's very simple, but the answer has eluded me. Thanks! ~Andrew

Instead of doing a radius search you can use a bounding box and page through the results if there is more than 250 (max results per query) by using the $top and $skip parameters. In theory you could download a full data source if you used a global bounding box and stepped through all results.

Here is an example: https://bingmapsv8samples.azurewebsites.net/#Load%20all%20results%20(parallel)

Just in case you hadn't noticed, the Contoso coffee data source is an example data source with fake coffee shop listings. It's primarily for testing/example use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM