2012-02-09 7 views
4

30 초마다 마커를 다시로드하려는 동적 Ovi/Nokia지도에 문제가 있습니다. 마커는 XML에서 읽고 동적 콘텐츠가 있습니다. 버블을 제외하고는 모두 잘 작동합니다. 그것은로드에만 표시되고 첫 번째 새로 고침 마커는 더 이상 클릭 할 수 없습니다 (클릭하면 확대/축소됩니다).Nokia/Ovi 맵 문제 - 동적 마커 새로 고침

var infoBubbles = new nokia.maps.map.component.InfoBubbles(); 
    map.addComponent(infoBubbles); 

은 행 앞에 위치해야합니다 :

<script> 
var markerCoords; 
var mapContainer; 
var container; 
var myMap; 
var bubbles=new Array(); 

// When the HTML page body section is loaded this function will be called. 
// This function gets passed the marker XML data file name 
var updateTime=30; 
var updateTime=1000*updateTime; 
var markerUpdate=self.setInterval("placeMarkersOnMaps('geomarkers.xml')",updateTime); 
function placeMarkersOnMaps(filename) 
{ 
var counter = 0; 
$.ajax({ 
    type: "GET", 
    url: filename , 
    dataType: "xml", 
    success: parseXml, 
       error : err 
    }); 

} 
function err(){ 
     alert("An Error has occurred."); 
} 

// Here we create an Nokia Maps within a Container. 

mapContainer = document.getElementById("mapContainer"); 


myMap = nokia.maps.map,  
       map = new myMap.Display(mapContainer, { 
        center: [52.59, 13.3], zoomLevel: 2, 
        components: [ new myMap.component.Behavior(), 
            new nokia.maps.map.component.ZoomBar(), 
            new nokia.maps.map.component.Overview(),        
            new nokia.maps.map.component.TypeSelector(),  
            new nokia.maps.map.component.ScaleBar() 
        ] 
       }); 



    placeMarkersOnMaps('geomarkers.xml'); 






     function deleteMarker(coords) { 
      var marker; 
      for (i=0; i< map.objects.getLength(); i++) { 
       if (map.objects.get(i) instanceof nokia.maps.map.StandardMarker) { 
        if (coords.latitude == map.objects.get(i)..coords.latitude 
        && coords.longitude == map.objects.get(i)..coords.longitude){ 
         marker = map.objects.get(i); 
         marker.removeListener("click", function(evt) { infoBubbles.addBubble(evt.target.$html, evt.target.coordinate);}, false);; 
         map.objects.remove (marker); 
         break; 
        } 
       } 
      } 
      return marker; 
     } 
function parseXml(xml) 
{ 
    var infoBubbles = new nokia.maps.map.component.InfoBubbles(); 
    map.addComponent(infoBubbles); 
    var container = new nokia.maps.map.Container(); 
    $(xml).find("marker").each(function(){ 

      //Read the name, address, latitude and longitude for each Marker 
      var nme = $(this).find('name').text(); 
      var address = $(this).find('address').text(); 
      var lat = $(this).find('lat').text(); 
      var lng = $(this).find('lng').text(); 
      var zhtml = $(this).find('zhtml').text(); 
      var zcolor = $(this).find('zcolor').text(); 

      //Put each marker on the map as the data has been read. 

      var markerCoords = new nokia.maps.geo.Coordinate(parseFloat(lat), parseFloat(lng));  

      var marker = new nokia.maps.map.StandardMarker(markerCoords, {text:nme, brush:{color:zcolor}, $html:zhtml}); 
      marker.addListener('click' , function(evt) { infoBubbles.addBubble(evt.target.$html, evt.target.coordinate);}, false); 
      container.objects.add(marker);  

     }); 
     // Add the marker container . 
     map.objects.add(container); 
     // Zoom into the markers. 



} 


</script> 
그것은 infobubble을 intialising 라인처럼 보이는

답변

2

가 잘못된 위치에 있습니다 : 나는 업데이트 된 마커가 너무 거품의 최신 HTML 콘텐츠를 표시 할

placeMarkersOnMaps('geomarkers.xml'); 

그렇지 않으면 placeMarkersOnMaps()가 실행될 때마다 정보 거품 구성 요소를 추가하려고합니다. 일반적으로 하나만 있습니다.

은 또한 당신의 deleteMarkers 기능은

myMap.objects.clear(); 
로 대체 될 수있다