0

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 インデックスで作成されているため、ポップアップは常にマーカーが追加された順序で表示され、最新のマーカーのポップアップが常に一番上に表示されることです。

最近追加されたマーカーではなく、最後にクリックされたマーカーポップアップが一番上になるように変更する方法はありますか? Firebug で z-index を手動で変更しようとしましたが (テストとして)、前面に表示されません。ポップアップやマーカーを削除して再作成するのは避けたいのですが、それが唯一の解決策のようです。

4

3 に答える 3

3

jQueryを使用して、zindexこのようなトリックを作成できます

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);
于 2013-05-04T05:03:53.213 に答える
1

z-index を確実に変更して機能させる方法がわかりませんでしたが、マップ マーカーを前面に配置したいときに完全に削除してから新しいクローンを作成することで問題を解決できました。

于 2012-11-15T00:01:03.090 に答える
0

call ms.setZIndex(100000);wheremsはマーカーのコンテナー (のインスタンスOpenLayers.Layer.Markers) です。

于 2013-12-27T06:34:34.023 に答える