Bing maps 7.0 Geocode Rest服务未调用回调函数



嗨,我正在使用bing maps 7.0 ajax api来显示地图。我有几个地址,我在javascript中使用rest服务来获取纬度和经度。我在geocode请求中设置了GeocodeCallback方法。

geocodeRequest =" http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials;CallRestService (geocodeRequest);

当地址被发现时,我在我的GeocodeCallback函数中得到响应,但对于少数地址,我没有得到响应。如何找出这个状态和错误。

我明白了。所以基本上你需要做两件事。

    你需要改变你的URL结构。我发现有时候如果我有一个奇怪的地址,bing会返回一个400。
  • 使用suppressStatus参数并将其设置为true。我现在找不到文档,但基本上我发现,如果bing返回400,404等,它实际上不会调用callBack函数。所以suppressstatus表示,无论如何,总是返回一个200。

原来你有:

http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials;

所以你想这样做:

http://dev.virtualearth.net/REST/v1/Locations?addressLine="+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&suppressStatus=true&jsonso="+mapDataAddress[0]+"&key="+credentials;

还可以查看此处列出的使用Bing Maps REST服务的提示和技巧:http://www.bing.com/blogs/site_blogs/b/maps/archive/2013/02/14/bing-maps-rest-service-tips-amp-tricks.aspx

最新更新