From 7ff77d9d3d7960ae993bf5ef97a66dbb10f2496e Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 7 Sep 2012 12:40:00 -0700 Subject: [PATCH] Trigger map.updateSize() via a custom event --- app/assets/javascripts/map.js.erb | 4 ++++ app/views/site/_resize.html.erb | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) 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() { -- 2.39.5