<p>When I open <a href="https://www.openstreetmap.org/" rel="nofollow">https://www.openstreetmap.org/</a> and try to switch to the Transport Map in the Map Layers menu, I would expect the map style to change to the transport style and the new map tiles to load. Instead, the map area becomes just grey and no map is displayed. This seems to be somewhat random, i.e. it happens in about 50 % of cases when trying to switch the map style. Clicking the same map style again usually fixes it and takes me to the desired map.</p>
<p>This error is logged in the console:</p>
<pre><code>TypeError: e is undefined application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:formatted:11438
    getMapBaseLayerId application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:11438
    l index-8de4fda0f10c81f0db6593a86cdcf3e1310c83de0153758674c137b4d75f0cbb.js:1
    fire application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:5949
    removeLayer application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:8029
    onAdd index-8de4fda0f10c81f0db6593a86cdcf3e1310c83de0153758674c137b4d75f0cbb.js:1
    forEach (index):262
    onAdd index-8de4fda0f10c81f0db6593a86cdcf3e1310c83de0153758674c137b4d75f0cbb.js:1
    dispatch application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:2358
    handle application-599745f20aed1b16d8ce60962f4b3458793d7d0649ba3eb1139998ecbdb83231.js:2295
</code></pre>
<p>The code in question is this:</p>
<div class="highlight highlight-source-js"><pre>      <span class="pl-en">getMapBaseLayerId</span><span class="pl-k">:</span> <span class="pl-k">function</span> () {
        <span class="pl-k">var</span> e;
        <span class="pl-k">return</span> <span class="pl-c1">this</span>.<span class="pl-en">eachLayer</span>(<span class="pl-k">function</span> (<span class="pl-smi">t</span>) {
<span class="pl-k">>>></span><span class="pl-k">></span>      <span class="pl-smi">t</span>.<span class="pl-c1">options</span> <span class="pl-k">&&</span> <span class="pl-smi">t</span>.<span class="pl-c1">options</span>.<span class="pl-smi">keyid</span> <span class="pl-k">&&</span> (e <span class="pl-k">=</span> t)
        }),
        <span class="pl-smi">e</span>.<span class="pl-c1">options</span>.<span class="pl-smi">keyid</span>
      },</pre></div>
<p>When the error happens <code>options</code> is an empty object and <code>options.keyid</code> is undefined.</p>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/538109/56650606-aa94b000-6687-11e9-8d5e-ecdf10ec6f4b.png"><img src="https://user-images.githubusercontent.com/538109/56650606-aa94b000-6687-11e9-8d5e-ecdf10ec6f4b.png" alt="osm_getMapBaseLayerId" style="max-width:100%;"></a></p>
<p>My browser is Firefox 66.0.2 on Linux.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/2215">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLOPTVN7R4WVUEIXPIDPSAVAZANCNFSM4HICIJ4Q">mute the thread</a>.<img src="https://github.com/notifications/beacon/AAK2OLIDRKQ3X2PV2SRTJD3PSAVAZANCNFSM4HICIJ4Q.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Can’t switch to Transport Map: TypeError: e is undefined in getMapBaseLayerId (#2215)"}],"action":{"name":"View Issue","url":"https://github.com/openstreetmap/openstreetmap-website/issues/2215"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/2215",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/2215",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>