Make zoom to extent control extensible

This commit is contained in:
Guillaume Beraudo
2017-11-16 14:00:40 +01:00
parent 8e9b69cb9b
commit 94e821f9bf

View File

@@ -22,9 +22,9 @@ ol.control.ZoomToExtent = function(opt_options) {
/**
* @type {ol.Extent}
* @private
* @protected
*/
this.extent_ = options.extent ? options.extent : null;
this.extent = options.extent ? options.extent : null;
var className = options.className !== undefined ? options.className :
'ol-zoom-extent';
@@ -62,16 +62,16 @@ ol.inherits(ol.control.ZoomToExtent, ol.control.Control);
*/
ol.control.ZoomToExtent.prototype.handleClick_ = function(event) {
event.preventDefault();
this.handleZoomToExtent_();
this.handleZoomToExtent();
};
/**
* @private
* @protected
*/
ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
ol.control.ZoomToExtent.prototype.handleZoomToExtent = function() {
var map = this.getMap();
var view = map.getView();
var extent = !this.extent_ ? view.getProjection().getExtent() : this.extent_;
var extent = !this.extent ? view.getProjection().getExtent() : this.extent;
view.fit(extent);
};