2016-11-12 11 views
0

おはよう、zIndex on Label

私のマーカーのラベルのzindexに問題があります。 ZIndexは、マーカータイプイメージで尊敬されているが、私はラベルを追加しようとしたとき:のZIndexは、ラベルに適用されません。私は、コードを使用enter image description here

は以下を参照:

var features = []; 
var myStyle = new ol.style.Style({zIndex: 1,image: new ol.style.Icon(({anchor: [0.5, 74],anchorXUnits: 'fraction',anchorYUnits: 'pixels',src: '/css/images/markerB.png'})),text: new ol.style.Text({font: '100 28px icon_set_1',text: "Z",offsetY: -52,fill: new ol.style.Fill({color: 'black'})})}); 
var lat = 3; 
for(i=0;i<=0.5;i+=0.1) { 
    var lon = 50 + i; 
    var iconFeature = new ol.Feature({geometry: new ol.geom.Point(ol.proj.transform([lon,lat], 'EPSG:4326',  'EPSG:3857'))}); 
    iconFeature.setStyle(myStyle); 
    features.push(iconFeature); 
} 
vectorSource = new ol.source.Vector({features: features});vectorLayer = new ol.layer.Vector({source: vectorSource});map.addLayer(vectorLayer); 

は、誰かが私に言うことができるとすることができ、私が間違って何をやっていますか? ありがとうございます。

答えて

0

は親切に、このコードをチェックし、ここでフィドルhttp://jsfiddle.net/n4h77xnz/

var features = []; 
    var myStyle = new ol.style.Style({ 
     zIndex: 1, 
     image: new ol.style.Icon(({ 
      anchor: [0.5, 0.5], 
      scale: 0.4, 
      anchorXUnits: 'fraction', 
      anchorYUnits: 'pixels', 
      src: 'icon.png' 
     })), 
     text: new ol.style.Text({ 
      font: '100 22px icon_set_1', 
      text: "yz", 
      offsetY: 22, 
      fill: new ol.style.Fill({ 
       color: 'black' 
      }) 
     }) 
    }); 
    var lat = 3; 
    for (i = 0; i <= 0.5; i += 0.1) { 
     var lon = 50 + i; 
     console.log(lon, lat); 
     var iconFeature = new ol.Feature({ 
      geometry: new ol.geom.Point(ol.proj.transform([lat, lon], 'EPSG:4326', 'EPSG:3857')) 
     }); 
     iconFeature.setStyle(myStyle); 
     features.push(iconFeature); 
    } 
    vectorSource = new ol.source.Vector({ 
     features: features 
    }); 
    vectorLayer = new ol.layer.Vector({ 
     source: vectorSource 
    }); 
    map.addLayer(vectorLayer); 

    map.getView().fit(vectorLayer.getSource().getExtent(), map.getSize()) 
+0

である、それはあなたにとって有用であるならば、感謝をこの答えをupvoteすることを忘れないでください! – dev9

+0

返信いただきありがとうございますが、問題は変わりません。ズームアウトマーカーはウルがやろうと何overlap..thatトン、ラベルは、彼らがshouldn ...ある..soラッピングを超えているとき(ズームを試してみる) – Slayes

+0

http://jsfiddle.net/feg5um2t/を参照してください... – dev9