[openstreetmap/openstreetmap-website] Use baselayerchange/overlaylayerchange instead of layeradd/layerremove (PR #5474)
Anton Khorev
notifications at github.com
Tue Jan 14 23:42:05 UTC 2025
Leaflet ships with a layers control which lets you switch between layers. That thing is responsible for [firing `baselayerchange` events](https://github.com/Leaflet/Leaflet/blob/c511e66c20dce06ac05c43cf287b3ecdba00d924/src/control/Control.Layers.js#L319). We don't use this control because we have our own layers menu. Therefore we're responsible for firing that event, which we do: https://github.com/openstreetmap/openstreetmap-website/blob/914fff9d4dec3d502d524f5b0f60797f66f8af65/app/assets/javascripts/leaflet.layers.js#L70
The problem is that our layers menu is not the only thing that can switch layers. All other places where layer change happens need also to fire `baselayerchange`. I think that `map.updateLayers` is the only such place. Lack of `baselayerchange` there becomes more noticeable with this PR because it uses this event.
Similar story with `overlaylayerchange`, although it's not a standard Leaflet event. Leaflet layers controluses `overlayadd` and `overlayremove`.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5474#issuecomment-2591325668
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5474/c2591325668 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250114/da10e62f/attachment.htm>
More information about the rails-dev
mailing list