How to zoom on marker click event in Mapbox Leaflet?

早过忘川 提交于 2019-12-06 10:08:49

To get the latitude and longitude of the event, you must use e.latlng: latlng reference. Use this:

marker.on('click', function(e){
    map.setView(e.latlng, 13);
});

Try

marker.on('click', function(e){
    map.setView([e.latlng.lat, e.latlng.lng], 12);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!