2012-03-27 10 views
0

希望はすべてうまくいきます。Bing Maps、複数のジオコード検索結果の検索(意味:機能性)

私はバージョン7.0を使用しています。

今朝、私はかなり単純だと思っていたものと闘っていました。 Store Locatorシナリオでの代替検索結果の提供(ただ、ここのように - http://www.bing.com/maps

私はそうのようにBing MapsのRESTサービスへのジオコード要求を行います。

このすべてが素晴らしい作品!関数に返された結果をキャプチャして、ユーザーが一致するジオコードを持つクエリを入力している限り、それを解析できます。

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) 
    } 

エラー:私は未定義です.nameの[i]との.resources [i]はresult.resourceSetsを得続けます。

長さが時々1より大きいため、そこに埋もれていることは知っています! result.resourceSets [0] .resources.lengthは返されたジオコード結果の数ですか?

ありがとうございました!

答えて

0
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); 
     } 
関連する問題