Bing Maps Rest服务地理编码的多个位置

时间:2011-10-24 12:05:27

标签: geocoding bing-maps

目前,我有一个ASP应用程序,它从数据源中检索一组位置,然后使用Bing地图REST服务对地址进行地理编码,然后一次以10页结果显示在表格和地图上。 目前,应用程序按顺序处理位置......

    var geocodeRequest = "http://ecn.dev.virtualearth.net/REST/v1/Locations/" + fullAddress.replace('&', ' ').replace(',', ' ') + "?output=json&jsonp=GeocodeCallback&key=" + getCredentials;
    CallRestService(geocodeRequest);

    ......

    function GeocodeCallback(result) {
        if (result &&
                       result.resourceSets &&
                       result.resourceSets.length > 0 &&
                       result.resourceSets[0].resources &&
                       result.resourceSets[0].resources.length > 0) {

            // Set the map view using the returned bounding box
            var bbox = result.resourceSets[0].resources[0].bbox;
            var viewBoundaries = MM.LocationRect.fromLocations(new MM.Location(bbox[0], bbox[1]), new MM.Location(bbox[2], bbox[3]));
            map.setView({ bounds: viewBoundaries });

            // Add a pushpin at the found location
            MM.Location.prototype.locID = null;
            var location = new MM.Location(result.resourceSets[0].resources[0].point.coordinates[0], result.resourceSets[0].resources[0].point.coordinates[1]);
            location.locID = tableRowIndex;
            locs.push(location);

.....

有没有办法通过在一次调用中传递10个位置然后处理result.resourceSets [0],result.resourceSets [1]等来加快速度? 如何将多个地址传递给其余服务调用? (逗号消除了吗?)

由于

2 个答案:

答案 0 :(得分:1)

Bing有两个可通过REST访问的地理编码API。其中一个是你正在使用的那个,它一次只支持一个地址,另一个是Dataflow API,它是专为大批量处理而设计的。它们似乎都不适合您,因为您的系统目前正在设计中。

根据您从哪里获得街道地址(您提到的是“数据源”),您可以为数据源中的所有位置执行大批量地理编码 - 从请求时间移动地理编码批量处理,只需使用请求时地理编码来处理批处理尚未进行的处理。

答案 1 :(得分:0)

现在看来没有办法做到这一点。有人建议在javascript中支持native(我认为),但我认为它还没有实现。你想要一些并发性,你可以看看webworkers:

但IE尚未支持此功能。也许你可以尝试检查html5异步。我不知道它是否可以用于创建调用REST服务时创建的脚本元素。

相关问题