我试图检索作为自定义参数传递到Bing地图REST地理位置的jsonso状态对象的值(http://dev.virtualearth.net/REST/V1 /位置/ ...)。我可以在响应方法调用(使用网络监视器)中看到作为第二个参数返回的值,但似乎无法在代码中访问它。下面是回归方法看起来像(摘录):Bing Maps REST API - 如何检索自定义参数
jsonp1301929429652({ “authenticationResultCode”: “ValidCredentials”,...更多数据... “traceId”: “41a7523951964ae9a76ca4ea91c4e80f | CH1M001467 | 02.00.82.2800 | CH1MSNVM001383” },“我的自定义值”)
我试图把它捡起来的匿名方法,像这样:
$.getJSON(geocodeRequest, function (d, customParam) {
if (d != null && d.resourceSets.length > 0) {
var coordinates = d.resourceSets[0].resources[0].point.coordinates;
var loc = new Microsoft.Maps.Location(coordinates[0], coordinates[1]);
....
}
}
不幸的是,customParam永远是不确定的。我怎样才能得到这个价值?
好了,这是一个可测试的例子:
$(function() {
var mapOptions = {
credentials: "Your API Key"
}
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/US/Your State Abbrev/Your Zip/Your City/Your Street Address?jsonso=ABC123&jsonp=?&key=" + mapOptions.credentials;
$.getJSON(geocodeRequest, function (d, arg1, arg2, arg3) {
if (d != null && d.resourceSets.length > 0) {
var readMyCustomParam = arg1;
}
});
});
如果上破的getJSON内的第一行请求您可以监控流量,你会看到该请求的结果正确返回jsonso参数。然后我的问题是在javascript中阅读。这样做的全部目的是循环遍历经销商列表,异步地理定位,然后使用返回的标识符查找数组中的经销商以加载它的描述等等。
这是[链接](http://msdn.microsoft.com/zh-cn/library/ff701701。aspx)引用此REST方法 – Corgalore 2011-04-26 20:37:20