I am displaying markers on the map from geojson file. In current code when I hover over marker I can see the properties in the popup. I want to add fly to or zoom in marker exact location upon click on the marker.how can I achieve that.
cityMarker = new L.geoJson(city, {
onEachFeature: function(feature, layer) {
//if (feature.properties && feature.properties.name) {
if ( feature.properties.name) {
layer.bindPopup(feature.properties.name, {closeButton: false, offset: L.point(0, -2)});
layer.on('mouseover', function() { layer.openPopup(); });
layer.on('mouseout', function() { layer.closePopup(); });
}
},
pointToLayer: function (feature, latlng) {
var cityIcon = new L.Icon({
iconSize: [20, 20],
iconAnchor: [13, 27],
popupAnchor: [1, -20],
iconUrl: './css/img/marker-icon-red.png'
});
//return L.circleMarker(latlng);
return L.marker(latlng,{icon: cityIcon});
}
});
map.addLayer(cityMarker);