javascript 中心标记和弹出在地图上

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 中心标记和弹出在地图上相关的知识,希望对你有一定的参考价值。

var map = L.map('id_div').setView([51.505, -0.09], 13);

map.on('popupopen', function(e) {
    var px = map.project(e.popup._latlng); // find the pixel location on the map where the popup anchor is
    px.y -= e.popup._container.clientHeight/2 // find the height of the popup container, divide by 2, subtract from the Y axis of marker location
    map.panTo(map.unproject(px),{animate: true}); // pan to new center
});

以上是关于javascript 中心标记和弹出在地图上的主要内容,如果未能解决你的问题,请参考以下文章