<p></p>
<p dir="auto">Leaflet ships with a layers control which lets you switch between layers. That thing is responsible for <a href="https://github.com/Leaflet/Leaflet/blob/c511e66c20dce06ac05c43cf287b3ecdba00d924/src/control/Control.Layers.js#L319">firing <code class="notranslate">baselayerchange</code> events</a>. We don't use this control because we have our own layers menu. Therefore we're responsible for firing that event, which we do: <a href="https://github.com/openstreetmap/openstreetmap-website/blob/914fff9d4dec3d502d524f5b0f60797f66f8af65/app/assets/javascripts/leaflet.layers.js#L70">https://github.com/openstreetmap/openstreetmap-website/blob/914fff9d4dec3d502d524f5b0f60797f66f8af65/app/assets/javascripts/leaflet.layers.js#L70</a></p>
<p dir="auto">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 <code class="notranslate">baselayerchange</code>. I think that <code class="notranslate">map.updateLayers</code> is the only such place. Lack of <code class="notranslate">baselayerchange</code> there becomes more noticeable with this PR because it uses this event.</p>
<p dir="auto">Similar story with <code class="notranslate">overlaylayerchange</code>, although it's not a standard Leaflet event. Leaflet layers controluses <code class="notranslate">overlayadd</code> and <code class="notranslate">overlayremove</code>.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5474#issuecomment-2591325668">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLM5VFGU7TJR5GFACUL2KWOE3AVCNFSM6AAAAABUVSY6FWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJRGMZDKNRWHA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLNE6KTGB7Y5F5MBQKT2KWOE3A5CNFSM6AAAAABUVSY6FWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTU2OR66I.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5474/c2591325668</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5474#issuecomment-2591325668",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5474#issuecomment-2591325668",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>