1 $(document).ready(function () {
2 const id = $("#id-embed");
4 if (id.data("configured") === false) {
5 alert(I18n.t("site.edit.id_not_configured"));
9 const hash = location.hash.substring(1);
10 const hashParams = hash ? OSM.params(hash) : {};
11 const hashArgs = OSM.parseHash(location.hash);
12 const mapParams = OSM.mapParams();
13 const params = new URLSearchParams();
15 if (mapParams.object) {
16 params.set("id", mapParams.object.type + "/" + mapParams.object.id);
17 if (hashArgs.center) {
18 params.set("map", hashArgs.zoom + "/" + hashArgs.center.lat + "/" + hashArgs.center.lng);
20 } else if (id.data("lat") && id.data("lon")) {
21 params.set("map", "16/" + id.data("lat") + "/" + id.data("lon"));
23 params.set("map", (mapParams.zoom || 17) + "/" + mapParams.lat + "/" + mapParams.lon);
26 const passThroughKeys = ["background", "comment", "disable_features", "gpx", "hashtags", "locale", "maprules", "notes", "offset", "photo", "photo_dates", "photo_overlay", "photo_username", "presets", "source", "validationDisable", "validationWarning", "validationError", "walkthrough"];
27 for (const key of passThroughKeys) {
28 if (hashParams[key]) params.set(key, hashParams[key]);
31 if (mapParams.layers.includes("N")) params.set("notes", "true");
33 if (id.data("gpx")) params.set("gpx", id.data("gpx"));
35 id.attr("src", id.data("url") + "#" + params);