Leaflet 单击传单上的标记打开模式

Leaflet 单击传单上的标记打开模式,leaflet,leaflet.markercluster,Leaflet,Leaflet.markercluster,我有一张地图,上面有记号笔和记号笔 我想实现的是,当你点击一个标记时,会出现一个模态,其中包含诸如:纬度、经度等信息 我已经设法使它与layer.bindpoup(content)一起工作但我不知道如何将这些参数传递给click函数 我试过了 markers.on('click', function (e) { console.log('show'); var id = this.options.id; $(".modal-content

我有一张地图,上面有记号笔和记号笔

我想实现的是,当你点击一个标记时,会出现一个模态,其中包含诸如:纬度、经度等信息

我已经设法使它与
layer.bindpoup(content)一起工作但我不知道如何将这些参数传递给click函数

我试过了

markers.on('click', function (e) {
        console.log('show');
        var id = this.options.id;
        $(".modal-content").html('Marker id: ' + id);
        $('#emptymodal').modal('show');
        map.setView(e.target.getLatLng());
    });
但它不起作用

我把所有代码都留在这里了

PlaceMarker=L.CircleMarker.extend({
选项:{
id:“”
}
});
var数据=;
//创建地图实例
var map=L.map('map'{
中间:[39.4697500,-0.3773900],
缩放:10
});
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}'{
属性:“地图数据©;贡献者,图像©”,
maxZoom:18,
id:“地图盒/街道-v11”,
tileSize:512,
Zoomofset:-1,
accessToken:'XXXX'
}).addTo(地图);
//创建markerclustergroup
var markers=L.markerClusterGroup();
//创建geojson对象
让geojsonData=createGeoJson(数据);
函数createGeoJson(数据){
var geojson={
“类型”:“FeatureCollection”,
“特点”:[
]
};
//遍历数据数组
data.forEach(元素=>{
设marker=L.marker([element.Latitude,element.Longitude]);
让pntGeojson=marker.toGeoJSON();
pntGeojson.properties=element;
geojson.features.push(pntGeojson);
});
返回geoson;
}
//创建geojson实例
var categorynone=L.geoJson(geojsonData{
onEachFeature:功能(功能,图层){
let content=“”+
“Dirección:”+feature.properties.address++“Categoría:”+feature.properties.category+”;
},
pointToLayer:函数(geoObj、latLng){
返回L.标记(板条);
},
过滤器:功能(特征、图层){
返回feature.properties.category==“”;
}
});
var category1=L.geoJson(geojsonData{
onEachFeature:功能(功能,图层){
let content=“”+
“Dirección:”+feature.properties.address++“Categoría:”+feature.properties.category+”;
},
pointToLayer:函数(geoObj、latLng){
返回L.标记(板条);
},
过滤器:功能(特征、图层){
返回feature.properties.category==“categoria1”;
}
});
var category2=L.geoJson(geojsonData{
onEachFeature:功能(功能,图层){
let content=“”+
“Dirección:”+feature.properties.address++“Categoría:”+feature.properties.category+”;
},
pointToLayer:函数(geoObj、latLng){
返回L.标记(板条);
},
过滤器:功能(特征、图层){
返回feature.properties.category==“categoria2”;
}
});
var all=L.layerGroup([category1,category2,CategoryOne]);
控制层({
“全部”:全部,
“categorynone”:categorynone,
“类别1”:类别1,
“类别2”:类别2,
“集群”:标记,
}).addTo(地图);
markers.addLayer(全部);
markers.addTo(map);
控制台日志(标记);
//待办事项:阿霍拉·索洛·法尔塔·波拉奎亚的信息和萨卡拉的信息重现
标记。打开('单击',功能(e){
console.log('show');
var id=this.options.id;
$(“.modal content”).html('Marker id:'+id);
$('#emptymodal').modal('show');
set视图(e.target.getLatLng());
});
/*在地图上单击关闭模式*/
地图上('点击')功能(e){
console.log('Hide');
//$('.modal').modal('hide');
});
#地图,
#acf地图{高度:500px;}

纬度:

Longitud: