Improve type checking in ol.control.Zoom

This commit is contained in:
Tom Payne
2013-12-13 16:13:07 +01:00
parent 35768f8b48
commit 408a75426b

View File

@@ -2,10 +2,12 @@
goog.provide('ol.control.Zoom');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.View2D');
goog.require('ol.animation');
goog.require('ol.control.Control');
goog.require('ol.css');
@@ -77,8 +79,11 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta, browserEvent) {
browserEvent.preventDefault();
var map = this.getMap();
// FIXME works for View2D only
var view = map.getView().getView2D();
var currentResolution = view.getResolution();
var view = map.getView();
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 (this.duration_ > 0) {
map.beforeRender(ol.animation.zoom({
@@ -87,7 +92,7 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta, browserEvent) {
easing: ol.easing.easeOut
}));
}
var newResolution = view.constrainResolution(currentResolution, delta);
view.setResolution(newResolution);
var newResolution = view2D.constrainResolution(currentResolution, delta);
view2D.setResolution(newResolution);
}
};