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 中心标记和弹出在地图上的主要内容,如果未能解决你的问题,请参考以下文章

使用 OpenLayers,删除标记层和弹出窗口的正确方法是啥?

javascript 获取谷歌地图的可见部分,并将中心主标记设置为可见部分的中心

如何在注册表单中添加标记和中心地图 django-map-widget

Leaflet_创建地图(官网示例)

百度地图javascript api怎么实现自定义标记然后将多个标记点连线起来

MKAnnotation - 地图图钉标注弹出在其他地图图钉后面