Skip to content

Commit

Permalink
Factor out a public setBounds method
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Oct 20, 2012
1 parent 5197b4f commit c41eb1e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/locationfilter.js
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit c41eb1e

Please sign in to comment.