From c41eb1ed21a21c7aacc35933aef4e5ad175f3eb8 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 19 Oct 2012 10:10:17 -0700 Subject: [PATCH] Factor out a public setBounds method --- src/locationfilter.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/locationfilter.js b/src/locationfilter.js index af87c65..a5dea7a 100644 --- a/src/locationfilter.js +++ b/src/locationfilter.js @@ -120,6 +120,15 @@ L.LocationFilter = L.Class.extend({ return new L.LatLngBounds(this._sw, this._ne); }, + setBounds: function(bounds) { + this._nw = bounds.getNorthWest(); + this._ne = bounds.getNorthEast(); + this._sw = bounds.getSouthWest(); + this._se = bounds.getSouthEast(); + this._draw(); + this._callCallback("onChange"); + }, + isEnabled: function() { return this._enabled; }, @@ -332,19 +341,9 @@ L.LocationFilter = L.Class.extend({ /* Adjust the location filter to the current map bounds */ _adjustToMap: function() { - var mapBounds = this._map.getBounds(); - - this._nw = mapBounds.getNorthWest(); - this._ne = mapBounds.getNorthEast(); - this._sw = mapBounds.getSouthWest(); - this._se = mapBounds.getSouthEast(); - - this._draw(); + this.setBounds(this._map.getBounds()); this._map.zoomOut(); - - // Call change callback - this._callCallback("onChange"); - }, + }, /* Enable the location filter */ _enable: function() {