Improve type checking in ol.control.Zoom
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
goog.provide('ol.control.Zoom');
|
goog.provide('ol.control.Zoom');
|
||||||
|
|
||||||
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('goog.dom.TagName');
|
goog.require('goog.dom.TagName');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
goog.require('ol.css');
|
goog.require('ol.css');
|
||||||
@@ -77,8 +79,11 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta, browserEvent) {
|
|||||||
browserEvent.preventDefault();
|
browserEvent.preventDefault();
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
// FIXME works for View2D only
|
// FIXME works for View2D only
|
||||||
var view = map.getView().getView2D();
|
var view = map.getView();
|
||||||
var currentResolution = view.getResolution();
|
goog.asserts.assert(goog.isDef(view));
|
||||||
|
var view2D = view.getView2D();
|
||||||
|
goog.asserts.assertInstanceof(view2D, ol.View2D);
|
||||||
|
var currentResolution = view2D.getResolution();
|
||||||
if (goog.isDef(currentResolution)) {
|
if (goog.isDef(currentResolution)) {
|
||||||
if (this.duration_ > 0) {
|
if (this.duration_ > 0) {
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
@@ -87,7 +92,7 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta, browserEvent) {
|
|||||||
easing: ol.easing.easeOut
|
easing: ol.easing.easeOut
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
var newResolution = view.constrainResolution(currentResolution, delta);
|
var newResolution = view2D.constrainResolution(currentResolution, delta);
|
||||||
view.setResolution(newResolution);
|
view2D.setResolution(newResolution);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user