No need to impl setMap in ZoomToExtent control

This commit is contained in:
Éric Lemoine
2013-07-11 14:47:37 +02:00
parent 74f446948f
commit 907476f566
2 changed files with 3 additions and 15 deletions

View File

@@ -1,2 +1 @@
@exportClass ol.control.ZoomToExtent ol.control.ZoomToExtentOptions
@exportProperty ol.control.ZoomToExtent.prototype.setMap

View File

@@ -62,18 +62,7 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function(browserEvent) {
browserEvent.preventDefault();
var map = this.getMap();
var view = map.getView().getView2D();
view.fitExtent(this.extent_, map.getSize());
};
/**
* Overload setMap to use the view projection's validity extent
* if no extent was passed to the constructor.
* @param {ol.Map} map Map.
*/
ol.control.ZoomToExtent.prototype.setMap = function(map) {
ol.control.Control.prototype.setMap.call(this, map);
if (map && !this.extent_) {
this.extent_ = map.getView().getProjection().getExtent();
}
var extent = goog.isNull(this.extent_) ?
view.getProjection().getExtent() : this.extent_;
view.fitExtent(extent, map.getSize());
};