1 $(document).ready(function () {
2 const id = $("#id-embed");
4 if (id.data("configured") === false) {
5 // eslint-disable-next-line no-alert
6 alert(I18n.t("site.edit.id_not_configured"));
10 const hash = location.hash.substring(1);
11 const hashParams = hash ? OSM.params(hash) : {};
12 const hashArgs = OSM.parseHash(location.hash);
13 const mapParams = OSM.mapParams();
14 const params = new URLSearchParams();
16 if (mapParams.object) {
17 params.set("id", mapParams.object.type + "/" + mapParams.object.id);
18 if (hashArgs.center) {
19 params.set("map", hashArgs.zoom + "/" + hashArgs.center.lat + "/" + hashArgs.center.lng);
21 } else if (id.data("lat") && id.data("lon")) {
22 params.set("map", "16/" + id.data("lat") + "/" + id.data("lon"));
24 params.set("map", (mapParams.zoom || 17) + "/" + mapParams.lat + "/" + mapParams.lon);
27 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"];
28 for (const key of passThroughKeys) {
29 if (hashParams[key]) params.set(key, hashParams[key]);
32 if (mapParams.layers.includes("N")) params.set("notes", "true");
34 if (id.data("gpx")) params.set("gpx", id.data("gpx"));
36 id.attr("src", id.data("url") + "#" + params);