5 document.addEventListener("DOMContentLoaded", function () {
6 var container = document.getElementById("id-container");
8 if (typeof iD === "undefined" || !iD.utilDetect().support) {
9 container.innerHTML = "This editor is supported " +
10 "in Firefox, Chrome, Safari, Opera and Edge. " +
11 "Please upgrade your browser or use JOSM to edit the map.";
12 container.className = "unsupported";
14 var idContext = iD.coreContext();
15 idContext.connection().apiConnections([]);
16 var url = location.protocol + "//" + location.host;
19 apiUrl: url === "https://www.openstreetmap.org" ? "https://api.openstreetmap.org" : url,
20 access_token: container.dataset.token
26 .assetMap(JSON.parse(container.dataset.assetMap))
27 .locale(container.dataset.locale)
28 .containerNode(container)
31 if (parent === window) {
32 // iD not opened in an iframe -> skip setting of parent handlers
36 var hashChangedAutomatically = false;
37 id.map().on("move.embed", parent.$.throttle(250, function () {
38 if (id.inIntro()) return;
39 var zoom = ~~id.map().zoom(),
40 center = id.map().center(),
41 llz = { lon: center[0], lat: center[1], zoom: zoom };
43 parent.updateLinks(llz, zoom);
45 // Manually resolve URL to avoid iframe JS context weirdness.
46 // https://gist.github.com/jfirebaugh/5439412
47 var hash = parent.OSM.formatHash(llz);
48 if (hash !== parent.location.hash) {
49 hashChangedAutomatically = true;
50 parent.location.replace(parent.location.href.replace(/(#.*|$)/, hash));
54 function goToLocation(data) {
55 // 0ms timeout to avoid iframe JS context weirdness.
56 // https://gist.github.com/jfirebaugh/5439412
57 setTimeout(function () {
60 Math.max(data.zoom || 15, 13));
64 parent.$("body").on("click", "a.set_position", function (e) {
66 var data = parent.$(this).data();
70 parent.addEventListener("hashchange", function (e) {
71 if (hashChangedAutomatically) {
72 hashChangedAutomatically = false;
76 var data = parent.OSM.mapParams();