必应地图,查找多个地理代码搜索结果(你的意思是:功能)
Bing Maps, Finding Multiple Geocode Search Results (Did you mean: Functionality)
希望一切顺利。
我使用的是7.0版。
今天早上,我在为一些我认为应该很简单的事情而挣扎。在商店定位器场景中提供替代搜索结果。(就像这里一样——http://www.bing.com/maps)
我向Bing Maps Rest服务提出了一个地理编码请求,如下所示:
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?query=" + encodeURI(searchString) + "&output=json&jsonp=GeocodeCallbackSearch&key=" + credentials;
这一切都很棒!只要用户输入了具有匹配地理代码的查询,我就可以将返回的结果捕获到函数中并对其进行解析。
function GeocodeCallbackSearch(result) {
try
{
alert(result.resourceSets[0].resources.length);
// When the user searches an address that isn't quite right, I notice that the
// Length of the result set is greater then 1.
// I would like to get at these so I can provide the "Did you Know"
// functionality.
// This is where I am having problems accessing the other results
for (var i =0; i < result.resourceSets[0].resources.length;i++)
{
alert (result.resourceSets[i].resources[i].name);
}
}
catch(err){
alert(err.message)
}
错误:我一直在获取结果。resourceSets[I].resources[I].name未定义。
我知道它们埋在那里的一些地方,因为长度有时大于1!我是否理解result.resourceSets[0].resources.length是返回的地理编码结果的计数?
提前感谢!
for (var i =0; i < result.resourceSets[0].resources.length;i++)
{
alert (result.**resourceSets[i]**.resources[i].name);
}
很容易修复,当然,粗体需要更改!
// This is where I am having problems accessing the other results
for (var i =0; i < result.resourceSets[0].resources.length;i++)
{
alert (result**.resourceSets[0]**.resources[i].name);
}
相关文章:
- AngularJS/HTML/Bootstrap元素用于动态搜索结果
- 在web应用程序中的新搜索中重新加载搜索结果(不带jQuery)
- 什么'它的意思是当一个变量位于括号外时
- 检查搜索结果是否存在多次如果是,则在Javascript中只显示一个结果
- 显示可链接的搜索结果+对齐方式
- 谷歌位置服务附近搜索结果基于正确的地图中心的位置
- 什么意思是“;向原型添加方法”;
- 什么是“;传递给NewPromiseCapability的非构造函数值“;意思是
- 为自定义网站创建JavaScript搜索框,创建显示搜索结果的弹出窗口
- 什么是“;(''+元素+'')“;意思是
- 主干,如何记住搜索结果
- 为什么不'我的扩展程序不会出现在Chrome网上商店的搜索结果中
- 如何从谷歌自定义搜索下载搜索结果
- (临时)在Web应用程序中存储JSON搜索结果
- Angular JS根据搜索结果和点击事件更新DOM元素
- 如何获得谷歌搜索结果?最好是Json
- 必应地图,查找多个地理代码搜索结果(你的意思是:功能)
- “搜索”什么?word/command在JS中的意思是
- JavaScript RegExp测试方法工作不稳定,我的意思是第一次执行和第二次执行的结果不同
- 什么是最好的方式拉搜索结果从任何谁.com到一个iframe在我的网站