首页 / 浏览问题 / 云GIS / 问题详情
无法选中位于 overlay层的svg渲染图层
2EXP 2019年04月10日

L.supermap

.featureService(mapDataUrl)

.getFeaturesBySQL(sqlParam, function(serviceResult) {

var features = serviceResult.result.features;

var feature = features.features[0];

var result = feature.properties;

window.console.log(feature);

window.console.log(result);

resultLayer = L.geoJSON(feature, {

style: function() {

return {

     color: "black",

     opacity: 0.8,

     weight: 2,

     fillColor: mapColor,

      fillOpacity: 0.7

};

},

onEachFeature: function (feature, layer) {

window.console.log(feature)

window.console.log(layer)

// layer.bindPopup("我被带那借来");

// layer.on("click" , function(e){

// var marker = L.marker(e.latlng).addTo(_this.map);

// var html="<b> marker:"+e.latlng+"</b>"

// marker.bindPopup(html).openPopup();

// _this.map.setView(e.latlng,12);

// alert("我被点击了")

// });

layer.bindPopup(function(layer){ return layer.feature.properties.NAME} )

}

}).addTo(_this.map);

window.console.log(resultLayer)

});

始终无法触发这个绑定的弹窗事件。可能的原因就是我其实在点击图层的时候,并没有点击到有颜色的图层。简单的说,就是我无法点击到这个图层,也就无法触发这个绑定的弹窗事件。可是leaflet的每个窗格的z-index是设置好的。overlay窗格应该是位于底图的上方。可为啥无法选中尼。??,

大神们有啥见解。

1个回答

你好,onEachFeature 打印下layer,看打印出来的layer中是否有

3,352EXP 2019年04月11日

layer中是有的,,

加我,如果你引入其他的css框架之类的,先把l注释了,然后再看看情况
...