2012-06-19 8 views
0

은 내가 OpenLayers 년과 같이 선언하고있어 팝업이 있습니다OpenLayers에서 마커 팝업을 앞에 가져 오는 방법은 무엇입니까?

var feature = new O[penLayers.Feature(markers, lonLat); 
feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, { 
    'autoSize': true; 
    'maxSize': new OpenLayers.Size(500, 300) 
}); 

문제는 내지도에 여러 팝업이 연속 Z - 인덱스 생성되는 것을 때문에 팝업이 항상에 표시됩니다 마커가 추가 된 순서이며 가장 최근 마커의 팝업이 항상 위에 표시됩니다.

가장 최근에 추가 된 마커 팝업 대신에 가장 최근에 클릭 한 마커 팝업이 위에 표시되도록 변경할 수 있습니까? 수동으로 방화 광 (테스트)으로 z- 인덱스를 변경하려고 시도했지만 앞쪽으로 가져 오지 않았습니다. 차라리 팝업이나 마커를 삭제하고 다시 작성하는 것을 피할 수는 있지만 찾을 수있는 유일한 해결책 인 것 같습니다.

답변

1

안정적으로 Z- 인덱스를 변경하고 작동시키는 방법을 찾지 못했지만 완전히 제거한 다음지도 마커의 새로운 복제본을 만들면 문제를 해결할 수있었습니다. 앞.

3

당신은 ms 마커 (OpenLayers.Layer.Markers의 인스턴스)의 컨테이너이

clientesLayer = new OpenLayers.Layer.Vector("PuntosVentas"); 


feature = new OpenLayers.Feature.Vector(
    new OpenLayers.Geometry.Point(vectorFatri.puntos[index][0],vectorFatri.puntos[index][1]), 
    {description: '<div><div class="popup_title"><h4>'+vectorFatri.imei+'</h4></div><div class="popup_content">'+vectorFatri.fecha[index]+'</div></div>'} , 
    { 
     strokeColor: "#00FF00", 
     strokeOpacity: 1, 
     strokeWidth: 2, 
     fillColor: "#FF5500", 
     fillOpacity: 0.5, 
     pointRadius: 6, 
     pointerEvents: "visiblePainted" 
    } 
); 

controls = { 
    selector: new OpenLayers.Control.SelectFeature(clientesLayer, { 

     onSelect: function (feature) { 
      feature.popup = new OpenLayers.Popup.FramedCloud("pop", 
        feature.geometry.getBounds().getCenterLonLat(), 
        new OpenLayers.Size(300,200), 
        '<div class="markerContent">'+feature.attributes.description+'</div>', 
        null, 
        true, 
        function() { controls['selector'].unselectAll(); } 
      ); 
      map.addPopup(feature.popup); 
      {# console.log('me seleccionaron');#} 

      //jquery trick to make the popup front of everything 
      $(".olPopup").css("z-index", 10000) 

      {# setTimeout(function(){$(".olPopup").css("z-index", 10000);}, 2000);#} 
     }, 

     onUnselect: function (feature) { 
      map.removePopup(feature.popup); 
      feature.popup.destroy(); 
      feature.popup = null; 
     } 
    }) 
} 

map.addControl(controls['selector']); 
controls['selector'].activate(); 
clientesLayer.addFeatures(feature); 
0

전화 ms.setZIndex(100000);처럼 zindex의 트릭을 만들기 위해 jQuery를 사용할 수 있습니다;

관련 문제