在宣传单张地图上,我加载并附加了两个不同的geojson,但鼠标单击不适用于附加的两个。在一个geojson上,我希望可以单击,而另一个则不能。是-有这样做的方法吗?
这是我的代码,我在同一页面上加载多个地图,每个地图带有两个geojson:
(function($){
var map = L.map('mapcontainer').setView([45.760612, 6.333560], 16);
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: '© <a href="http://www.esri.com/">Esri</a>, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
maxZoom: 18,
id: 'map'
}).addTo(map);
$.getJSON( "/media/kml/building.geojson").done(function( databuilding ) {
function onEachFeature(feature, layer) {
var popupContent = "<p>Building " +
feature.properties.Name;
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
layer.bindPopup(popupContent);
}
L.geoJSON(databuilding, {
style: function (feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON( "/media/kml/zone.geojson").done(function( datazone ) {
L.geoJSON(datazone
).addTo(map);
});
})(jQuery);
多谢
答案 0 :(得分:0)
我已经反转了图层的加载,因为这只是考虑事件的最后一个