leaflet-control-geocoder icon indicating copy to clipboard operation
leaflet-control-geocoder copied to clipboard

how to set custom zoom into map when location found

Open marketdevsoft opened this issue 1 year ago • 2 comments

Hi, i need to change default map-zoom level of search result. I try with this code but doesn't work :

        .on('markgeocode', function(e) {
            map.setZoomAround(e.geocode.bbox.getCenter(), 10);
        }) 

Can someone help me?

marketdevsoft avatar Mar 08 '24 16:03 marketdevsoft

I have the same problem

analoghifi avatar Oct 09 '24 08:10 analoghifi

in the meantime found a workaround for me:

var initial_zoom = 17;
.
.
var map = L.map('map', mapOptions);
.
.
var myGeocoder = L.Control.geocoder(geoCoderOptions).addTo(map);
.
.
myGeocoder.on('markgeocode', function(e) {
	map.setZoom(initial_zoom, {animate: false});
});

analoghifi avatar Oct 18 '24 07:10 analoghifi