我创建了几个 geoJSON 层。每个图层对象都有许多属性。当您单击任何图层的对象时,会显示一个弹出窗口,其中包含一个按钮,该按钮应显示有关图层和对象的扩展信息。如何:
<div id="map" style="width: 600px; height: 400px;"></div>
<script>
let map = L.map('map').setView([10.1497326, -67.9283981], 7);
let data1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-67.9283981, 10.1497326]
},
"properties": {
"id": 10,
"text": "Marker1"
}
}]
};
let data2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-68.9283981, 11.1497326]
},
"properties": {
"id": 20,
"text": "Marker2"
}
}]
};
let lay1 = L.geoJson(data1, {
onEachFeature: function(feature, …Run Code Online (Sandbox Code Playgroud)