Bing地图,如何在7版本中发出地理编码请求而不回调?
我知道如何使用回调函数发出 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) {
...
});
这非常有用,因为所有变量已定义并准备使用,但在新版本中,我的所有变量均未定义,我不想将它们作为全局变量,所以您知道如何在没有此类回调的情况下发出请求的解决方案吗?
I know how to make bing geocode request with callback function, like this:
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
}
(Copied from msdn Maps AJAX Control 7.0 ISDK)
In Bing Map 6.2 version it was opportunity to make such request by using the next code:
map.Find(null, tempDest, null, null, null, null, null, null, null, null,
function (a, b, c, d, e) {
...
});
It was very useful because all variables were defined and ready to use, but in new version all my variables are undefined and I do not want do them as global, so do you know any solution how to make request without such callback?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来版本 7 不支持 6.x 方法。这是 7 的示例。
示例来自 http://www.bingmapsportal.com/isdk/ajaxv7#SearchModule2
只是添加了警报(topResult.location);线,以便您看到位置信息。
Looks like version 7 doesn't support the 6.x methods. Here's an example for 7.
Example is from http://www.bingmapsportal.com/isdk/ajaxv7#SearchModule2
Just added the alert(topResult.location); line so you see the location info.
在 url jsonso 参数中指定。
例子:
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + document.getElementById('txtQuery').value + "?jsonso=paramValue&output=json& ;jsonp=GeocodeCallback&key=" + 凭据;
Specify in url jsonso parameter.
Example:
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + document.getElementById('txtQuery').value + "?jsonso=paramValue&output=json&jsonp=GeocodeCallback&key=" + credentials;