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([]);
17 url: location.protocol + "//" + location.host,
18 access_token: container.dataset.token
24 .assetMap(JSON.parse(container.dataset.assetMap))
25 .locale(container.dataset.locale)
26 .containerNode(container)
29 id.map().on("move.embed", parent.$.throttle(250, function () {
30 if (id.inIntro()) return;
31 var zoom = ~~id.map().zoom(),
32 center = id.map().center(),
33 llz = { lon: center[0], lat: center[1], zoom: zoom };
35 parent.updateLinks(llz, zoom);
37 // Manually resolve URL to avoid iframe JS context weirdness.
38 // http://bl.ocks.org/jfirebaugh/5439412
39 var hash = parent.OSM.formatHash(llz);
40 if (hash !== parent.location.hash) {
41 parent.location.replace(parent.location.href.replace(/(#.*|$)/, hash));
45 parent.$("body").on("click", "a.set_position", function (e) {
47 var data = parent.$(this).data();
49 // 0ms timeout to avoid iframe JS context weirdness.
50 // http://bl.ocks.org/jfirebaugh/5439412
51 setTimeout(function () {
54 Math.max(data.zoom || 15, 13));