Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Request: keepCurrentZoomLevel within set range #246

Closed
barryhunter opened this issue Jul 16, 2019 · 1 comment · May be fixed by #247
Closed

Enhancement Request: keepCurrentZoomLevel within set range #246

barryhunter opened this issue Jul 16, 2019 · 1 comment · May be fixed by #247

Comments

@barryhunter
Copy link

keepCurrentZoomLevel in general is a nice option.

But think it would be even better to have a middle ground. Eg only keepCurrentZoomLevel if the current zoom is between say 13 and 18.
... so if below 13 (zoomed out) would zoom in.
... and if zoomed in beyond 18 it could zoom out (assuming maxZoom was set to say 16)

This would give best of both worlds? If the user is zoomed way out (say country level) then it would zoom in to show the proper position. But if they've already set to a nice midscale, it would keep it, rather than switching to the exact option the developer choose.

@barryhunter
Copy link
Author

Just in case anyone wants to see it, here is map using the forked version
https://www.geograph.org/leaflet/all.php

https://github.com/barryhunter/leaflet-locatecontrol/

    L.control.locate({
            keepCurrentZoomLevel: [13,17],
            locateOptions: {
                    maxZoom: 16,
                    enableHighAccuracy: true
    }}).addTo(map);

If the user is already within 13->17, the map will keep the current zoom (lets them keep their chosen mid-level zoom) - only zooms (honouring maxZoom), if outside the range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants