From: John Firebaugh Date: Fri, 7 Sep 2012 19:40:00 +0000 (-0700) Subject: Trigger map.updateSize() via a custom event X-Git-Tag: live~5914 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7ff77d9d3d7960ae993bf5ef97a66dbb10f2496e?ds=sidebyside Trigger map.updateSize() via a custom event --- diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index d976b9f8c..c97dc76c3 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -71,6 +71,10 @@ function createMap(divName, options) { }); map.addLayer(markers); + $("#" + divName).on("resized", function () { + map.updateSize(); + }); + return map; } diff --git a/app/views/site/_resize.html.erb b/app/views/site/_resize.html.erb index 3e371a417..4b312bf8c 100644 --- a/app/views/site/_resize.html.erb +++ b/app/views/site/_resize.html.erb @@ -35,10 +35,7 @@ <% end -%> $("#map").width(content_width - sidebar_width - left_border - right_border); $("#map").height(content_height - top_border - bottom_border); - - <% if params[:controller] == "site" and params[:action] == "index" -%> - map.updateSize(); - <% end -%> + $("#map").trigger("resized"); } function handleResize() {