简体   繁体   English

在 Bing 地图中显示来自数据源 URL 的所有营业地点

[英]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对于商店定位器,假设我使用 Bing 的示例数据源网址: https://spatial.virtualearth.net/REST/v1/data/515d38d4d4e348d9a61c615f59704174/CoffeeShops/CoffeeShop : 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.在 Bing 的示例中,用户必须搜索才能填充商店位置,如果您是 Starbuck 并且您有数千个位置,这很好,但业务要求是我们需要在上显示我们所有的 10-15 个位置全美国的地图。

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.看起来有很多模块可用于搜索和查找框中的所有位置,或查找指定半径内的附近位置,将视口内的许多位置聚集在一起,但我一生都无法弄清楚如何只需从数据源 URL 加载所有 Contoso Coffee 位置。

The closest answer that I could find is this: Zoom to show all locations in bing maps The chosen answer:我能找到的最接近的答案是: 缩放以显示 bing 地图中所有位置所选的答案:

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.这不起作用,因为 1000 是最大半径,而我的一些位置将在它之外。

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.如果使用 $top 和 $skip 参数超过 250 个(每个查询的最大结果),您可以使用边界框和翻阅结果,而不是进行半径搜索。 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)这是一个例子: 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.以防万一您没有注意到,Contoso 咖啡数据源是一个包含假咖啡店列表的示例数据源。 It's primarily for testing/example use.它主要用于测试/示例使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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