我知道如何使用回调函数进行 bing 地理编码请求,如下所示:
function MakeGeocodeRequest(credentials)
{
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + document.getElementById('txtQuery').value + "?output=json&jsonp=GeocodeCallback&key=" + credentials;
CallRestService(geocodeRequest);
}
function CallRestService(request)
{
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", request);
document.body.appendChild(script);
}
function GeocodeCallback(result)
{
// Do something with the result
}
(复制自msdn Maps AJAX Control 7.0 ISDK)
在 Bing Map 6.2 版本中,可以使用以下代码发出此类请求:
map.Find(null, tempDest, null, null, null, null, null, null, null, null,
function (a, b, c, d, e) {
...
});
这非常有用,因为所有变量都已定义并可以使用,但在新版本中,我的所有变量都未定义,我不想将它们作为全局变量,所以您知道如何在没有此类回调的情况下发出请求的任何解决方案吗?