带标记小叶引导程序的开放式模态3 [英] open modal with marker leaflet bootstrap 3
本文介绍了带标记小叶引导程序的开放式模态3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在模态工作中显示了地图.现在我有一个新问题.我有不同的对象,我会将标记的坐标存储在id中.
i got the map showing in the modal working. now i have a new problem. i have different objects and i will store the coordinates for the marker in the id.
像这样:
<a href="#eintrag" id="[48.20682894891699, 16.370315551757812]" role="button" class="btn btn-primary" data-toggle="modal">Open Map</a>
这还将打开带有地图的模态. 那么我有这个:
this also opens the modal with the map. then i have this:
var map = L.map('map', {
center: new L.LatLng(48.20682894891699, 16.370315551757812),
zoom: 14,
maxBounds: bounds
});
jQuery(document).on("click", "a", function (event) {
id =jQuery(this).attr('id') || '';
console.log(id);
});
L.marker(id).addTo(map);
有人可以帮我吗? -地图是空白的:( 帮助多了!
can anyone help me out with this? - the map is blank :( help much apreciated!
推荐答案
入门的两件事:
- 您要在
undefined
时使用id
(单击a
时创建它) - 您不能使用字符串
id
来初始化标记,可以使用eval()
对其进行修复.
- You want to use
id
when it'sundefined
(you create it when you clicka
) - You can't use string
id
to init marker, you can fix it usingeval()
顺便说一句.要存储数据,可以使用data-id
代替id
.
BTW. For storing data you can use data-id
instead of id
.
这篇关于带标记小叶引导程序的开放式模态3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文