]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/id_iframe.html.erb
Fix search result link behavior (systemed/iD#1329)
[rails.git] / app / views / site / id_iframe.html.erb
index 515c0e8072ab423e31506294e9d29cd8dce93b48..b4cfaf46109479c124046f3ad67272101be56c99 100644 (file)
     parent.$("body").on("click", "a.set_position", function (e) {
       e.preventDefault();
       var data = parent.$(this).data();
-      id.map().centerZoom(
-        [data.lon, data.lat],
-        Math.max(data.zoom || 15, 13));
+
+      // 0ms timeout to avoid iframe JS context weirdness.
+      // http://bl.ocks.org/jfirebaugh/5439412
+      setTimeout(function() {
+        id.map().centerZoom(
+          [data.lon, data.lat],
+          Math.max(data.zoom || 15, 13));
+      }, 0);
     });
 
     var maximized = false;