Trigger map.updateSize() via a custom event
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 7 Sep 2012 19:40:00 +0000 (12:40 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 7 Sep 2012 20:04:48 +0000 (13:04 -0700)
app/assets/javascripts/map.js.erb
app/views/site/_resize.html.erb

index d976b9f8c9f0c82ef27010b9608257601ca7257d..c97dc76c324330fced074c3682724174a7cf188f 100644 (file)
@@ -71,6 +71,10 @@ function createMap(divName, options) {
    });
    map.addLayer(markers);
 
+   $("#" + divName).on("resized", function () {
+     map.updateSize();
+   });
+
    return map;
 }
 
index 3e371a417efdc0c2e5e24263947bfaa63bf4b696..4b312bf8c49927890a47d740a5f808df5800761b 100644 (file)
     <% 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() {