]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.sidebar.js
Round user home location to a sensible precision
[rails.git] / app / assets / javascripts / leaflet.sidebar.js
index f75cc29fe33f262539b1a12e53726f66cf26f5b4..8c4dee308ada2bb36068aaf2f7fe430a9501279c 100644 (file)
@@ -1,7 +1,13 @@
 L.OSM.sidebar = function(selector) {
   var control = {},
     sidebar = $(selector),
-    current = $();
+    current = $(),
+    map;
+
+  control.addTo = function (_) {
+    map = _;
+    return control;
+  };
 
   control.addPane = function(pane) {
     pane
@@ -10,22 +16,20 @@ L.OSM.sidebar = function(selector) {
   };
 
   control.togglePane = function(pane) {
-    var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
-
     current
       .hide()
       .trigger('hide');
 
     if (current === pane) {
       $(sidebar).hide();
-      controlContainer.css({paddingRight: '0'});
       current = $();
     } else {
       $(sidebar).show();
-      controlContainer.css({paddingRight: '250px'});
       current = pane;
     }
 
+    map.invalidateSize({pan: false, animate: false});
+
     current
       .show()
       .trigger('show');