有一个html表格中各个地方的经纬度,点击该行时,函数将纬度和经度值发送到一个javascript函数,该函数将openstreetmap地图和标记加载到bootstrap模态。 第一次调用此功能时,显示标记,但是关闭模式并重新调用函数我得到错误
未捕获错误:地图容器已经初始化。Leaflet:初始化地图容器的函数
function sendlatlng(id) {
var geom=document.getElementById('cor'+id).value;
var geom1=document.getElementById('cod'+id).value;
var map = L.map(('map'),{scrollWheelZoom:true}).setView([geom,geom1], 12);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
maxZoom: 18
}).addTo(map);
L.marker([geom,geom1]).addTo(map);
}
有没有一种方式,地图div
<div id="map" class="map" style="height: 300px;"></div>
重新初始化每一个模态被打开或函数被调用时。