[openstreetmap/openstreetmap-website] Fix location control toggle behavior (PR #7349)

Mohd Farhan Akhtar notifications at github.com
Mon Aug 31 11:37:22 UTC 2026


### Description

Fixes #7284.

When "Show My Location" is enabled and the map is then moved somewhere else, clicking the location button again moves the map back to the user's location instead of simply turning the feature off.

This happens because the location control uses `setView` when the user's location is outside the current map view. I changed the `clickBehavior` configuration so that clicking the button stops the location control instead, without moving the map.

### How has this been tested?

I tested the location control both when the user's location is visible and after moving the map away from it. In both cases, clicking the button turns off the location control without moving the map.

I also ran ESLint on `app/assets/javascripts/leaflet.locate.js` and the JavaScript assets, with no errors.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/7349

-- Commit Summary --

  * Fixed location reset error

-- File Changes --

    M app/assets/javascripts/leaflet.locate.js (5)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/7349.patch
https://github.com/openstreetmap/openstreetmap-website/pull/7349.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7349
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/7349 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260831/ece2381c/attachment.htm>


More information about the rails-dev mailing list