Zoom and center marker on click in leaflet
Instead of using setZoom
and panTo
, you can use single method setView
with zoomoption.
map.on('popupopen', function(centerMarker) {
var cM = map.project(centerMarker.popup._latlng);
cM.y -= centerMarker.popup._container.clientHeight/2
map.setView(map.unproject(cM),16, {animate: true});
});