smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.03k stars 273 forks source link

zoomLevel not working #233

Closed MaRaSu closed 3 years ago

MaRaSu commented 4 years ago

Hi,

zoomLevel-option does not seem to work, at least not how I was expecting it to work i.e. set the zoom if no bounds information is available for the selected search result. A quick look at SearchControl.centerMap() looks like it either uses bounds from search result (which e.g. Algolia is not providing for my searches) or a fixed 10 x 10 meter bounds.

retainZoomLevel can be used to prevent this overly tight zooming in, however I would rather not: If map is currently zoomed out to lets say level 11 and does a search for a street name then just doing map center of the street is not good UX. But neither is going all the way to max zoom in either (for my app at least).

Dusty211 commented 3 years ago

@MaRaSu I ran into the same issue. Suggested fix in pull request: https://github.com/smeijer/leaflet-geosearch/pull/270

smeijer commented 3 years ago

Fixed by #270