onAdd: function(map) {
this._map = map;
this._layer = new L.LayerGroup();
- this._initializeButtonContainer();
+
+ if (this.options.enableButton || this.options.adjustButton) {
+ this._initializeButtonContainer();
+ }
if (this.options.enable) {
this.enable();
onRemove: function(map) {
this.disable();
- this._buttonContainer.removeFrom(map);
+ if (this._buttonContainer) {
+ this._buttonContainer.removeFrom(map);
+ }
},
/* Get the current filter bounds */
this._ne = bounds.getNorthEast();
this._sw = bounds.getSouthWest();
this._se = bounds.getSouthEast();
- this._draw();
- this.fire("change", {bounds: bounds});
+ if (this.isEnabled()) {
+ this._draw();
+ this.fire("change", {bounds: bounds});
+ }
},
isEnabled: function() {
// Update buttons
- this._buttonContainer.addClass("enabled");
+ if (this._buttonContainer) {
+ this._buttonContainer.addClass("enabled");
+ }
if (this._enableButton) {
this._enableButton.setText(this.options.enableButton.disableText);
}
// Update buttons
- this._buttonContainer.removeClass("enabled");
+ if (this._buttonContainer) {
+ this._buttonContainer.removeClass("enabled");
+ }
if (this._enableButton) {
this._enableButton.setText(this.options.enableButton.enableText);
}).addTo(this._buttonContainer);
}
- if (this.options.enableButton || this.options.adjustButton) {
- this._buttonContainer.addTo(this._map);
- }
+ this._buttonContainer.addTo(this._map);
}
});