Open Daniel-Bozinovski opened 2 years ago
Looking at the code...
By default the map will zoom to fit the bounding box of the geometry (as defined by the 'bounds' property coming back from the geocoding provider).
For geometries without a 'bounds' property, (such as point-based geometries), the L.LatLng.toBounds()
function is called with sizeInMeters=10
, this is presumably very small and would trigger a max zoom.
https://github.com/smeijer/leaflet-geosearch/blob/develop/src/SearchControl.ts#L437
Once you've reached Leaflet's maximum zoom you cannot zoom any further.
Please provide more information about what you're trying to do and what data you're using.
There doesn't appear to be any simple way with the existing code to 'hack it', I didn't try it but maybe you can manually zoom and then set retainZoomLevel
?
Hey thanks for the reply!
So after I search for a location, the leaflet map re-centres on the address with some zoom level set automatically by geosearch. I want it to be more zoomed in (maybe around 20 zoom level) on the searched location but I'm not sure how to manually set it if you understand what I mean..
It's currently like this after I search for an address
but I want it to be like this
I think you'd be able to set updateMap
to false, so that the control doesn't zoom to the location at all. And next, you'll add your own handler to zoom/pan to the location on a match.
map.on('geosearch/showlocation', yourEventHandler);
Is there any way to be able to set the zoom level when you have searched for a specific place?