2013-10-21 45 views
0

我想實現這裏的地圖(asp.net網絡應用程序)的新結構,但是,我看不到通過位置信息傳遞和通過JavaScript和棒檢索某些地址的功能該信息與標記上的氣泡有關。反向地理編碼在這裏/諾基亞地圖

欣賞任何建議。 歡呼聲

+0

對不起,完全不清楚你在問什麼。你嘗試了什麼,你有什麼問題? –

+0

這是關於位置的屬性 - 它完成了。但是,我目前的問題是,如何多次調用reverseGeoCode方法在地圖上使用氣泡地址添加更多標記?我不能這樣做迴路: map.addListener( 「displayready」,函數(){ searchManager.reverseGeoCode({ 緯度:reverseGeoCodeTerm.latitude, 經度:reverseGeoCodeTerm.longitude, 的onComplete:processResults });} ) ;因爲我有更多的經驗 – mehmet

回答

0

我認爲你正在尋找多個併發的反向地理編碼請求。有在做這個沒有問題,因爲調用是異步的,你只需要保持對哪些請求已經完成計數,並打電話給你「辦後,所有完成的」末的東西一旦:

如:如圖所示

function concurrentSearch(map){ 
    // we will put our address markers into this container 
    addressContainer = new nokia.maps.map.Container(); 
    managersFinished = 0; 

    //Locations to be displayed 
    latLngs= [[10,30], [-117.5, 15.3] ... etc]; 
    var i = latLngs.length; 

    while(i--) { 
     nokia.places.search.manager.reverseGeocode({ 
      latitude: latLngs[i][0], 
      longitude: latLngs[i][1], 
      onComplete: processResults 
     }); 
    } 
} 

有了一個回調函數:

function processResults(data, requestStatus) { 
     if (requestStatus == "OK") { 
      // if we are finished, we add a marker for the mapped position 
      var marker = new nokia.maps.map.StandardMarker(data.location[0].position); 
      marker.content = data.location[0].address.text; // add your content here 
      addressContainer.objects.add(
       marker); 
      //increment the counter to notify another manager has finished 
      managersFinished++; 
     } else if(requestStatus === "ERROR") { 
      // we'll also increment in case of an error 
      managersFinished++; 
     } 

     // if all managers are finished, we call the final function 
     if(managersFinished === latLngs.length) { 
      onAllManagersFinished(); 
     } 
    } 

和最終清理:

function onAllManagersFinished() { 
     //we get the bounding box of the container 
     var bbox = addressContainer.getBoundingBox(); 

     // if the bounding box is null then there are no objects inside 
     // meaning no markers have been added to it 

     if (bbox != null) { 
       // we have at least one address mapped 
       // so we add the container and zoomTo it 
       map.objects.add(addressContainer); 
       map.zoomTo(bbox); 
     } else { 
       // otherwise we'll pop up an error message 
       alert("There are no addresses to show :("); 
     } 
    } 

Futhermore,你可以在容器,這可能打開infobubbles爲您所有的位置上添加一個事件處理程序:

addressContainer.addListener(
    "click", 
    function (evt) { 
     infoBubbles.openBubble(evt.target.content, // content is your own stuff... 
     evt.target.coordinate); 
    } 
); 

如果您需要更多的信息,通過反向地理編碼時,您可以按照問題here

中描述的方式進行操作。可以找到類似問題(多個地理編碼請求)的解決方案here