<p></p>
<p><b>@tomhughes</b> commented on this pull request.</p>
<p dir="auto">This looks pretty good - just a couple of minor suggestions that I've made inline.</p><hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5550#discussion_r1929720826">app/assets/javascripts/embed.js.erb</a>:</p>
<pre style='color:#555'>> @@ -15,14 +15,7 @@ I18n.default_locale = <%= I18n.default_locale.to_json %>;
I18n.fallbacks = true;
window.onload = function () {
- var query = (window.location.search || "?").slice(1),
- args = {};
-
- var pairs = query.split("&");
- for (var i = 0; i < pairs.length; i++) {
- var parts = pairs[i].split("=");
- args[parts[0]] = decodeURIComponent(parts[1] || "");
- }
+ var args = Object.fromEntries(new URLSearchParams(window.location.search).entries());
</pre>
<p dir="auto">Do you actually need <code class="notranslate">.entries()</code> here? I believe the <code class="notranslate">URLSearchParams</code> object itself should be iterable?</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5550#discussion_r1929721912">app/assets/javascripts/embed.js.erb</a>:</p>
<pre style='color:#555'>> - new L.OSM.CycleMap(thunderforestOptions).addTo(map);
- } else if (args.layer === "transportmap") {
- new L.OSM.TransportMap(thunderforestOptions).addTo(map);
- } else if (args.layer === "hot") {
- new L.OSM.HOT().addTo(map);
- } else {
- new L.OSM.Mapnik(mapnikOptions).addTo(map);
- }
+ var baseLayers = {
+ cyclosm: ["CyclOSM"],
+ cyclemap: ["CycleMap", thunderforestOptions],
+ transportmap: ["TransportMap", thunderforestOptions],
+ hot: ["HOT"],
+ mapnik: ["Mapnik", mapnikOptions]
+ };
+ baseLayers["cycle map"] = baseLayers.cyclemap;
</pre>
<p dir="auto">I think I'd just include this in the object definition after the <code class="notranslate">cyclemap</code> line. I realise it means duplicating the right hand side but I'm not sure that's any worse than this and I think it makes it a bit easier to see what's going on - also <code class="notranslate">baseLayers</code> could then be <code class="notranslate">const</code> I think?</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/5550#pullrequestreview-2574202826">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMWTMYPJLUXLMNY7X32MS757AVCNFSM6AAAAABV2NKF6SVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKNZUGIYDEOBSGY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMZLMJWL2UPDZQRYDT2MS757A5CNFSM6AAAAABV2NKF6SWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUZN434U.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/5550/review/2574202826</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/5550#pullrequestreview-2574202826",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5550#pullrequestreview-2574202826",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>