X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a9386e843d0804c03636841488b217303156dbf7..fd8a77552600ed2bff0bda0f0fd524a07998df4f:/app/views/site/id_iframe.html.erb diff --git a/app/views/site/id_iframe.html.erb b/app/views/site/id_iframe.html.erb index 515c0e807..b4cfaf461 100644 --- a/app/views/site/id_iframe.html.erb +++ b/app/views/site/id_iframe.html.erb @@ -47,9 +47,14 @@ 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;