From 35768f8b482c08a03e61ef13a565fd716049657d Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 13 Dec 2013 16:05:08 +0100 Subject: [PATCH] Improve type checking in ol.interaction.Interaction --- src/ol/interaction/interaction.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index f70bffabd2..2fdbf57cdf 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -2,8 +2,10 @@ goog.provide('ol.interaction.Interaction'); +goog.require('goog.asserts'); goog.require('goog.events.EventTarget'); goog.require('ol.MapBrowserEvent'); +goog.require('ol.View2D'); goog.require('ol.animation'); goog.require('ol.easing'); @@ -64,6 +66,7 @@ ol.interaction.Interaction.prototype.setMap = function(map) { */ ol.interaction.Interaction.pan = function( map, view, delta, opt_duration) { + goog.asserts.assertInstanceof(view, ol.View2D); var currentCenter = view.getCenter(); if (goog.isDef(currentCenter)) { if (goog.isDef(opt_duration) && opt_duration > 0) { @@ -89,6 +92,7 @@ ol.interaction.Interaction.pan = function( */ ol.interaction.Interaction.rotate = function(map, view, rotation, opt_anchor, opt_duration) { + goog.asserts.assertInstanceof(view, ol.View2D); rotation = view.constrainRotation(rotation, 0); ol.interaction.Interaction.rotateWithoutConstraints( map, view, rotation, opt_anchor, opt_duration); @@ -104,6 +108,7 @@ ol.interaction.Interaction.rotate = */ ol.interaction.Interaction.rotateWithoutConstraints = function(map, view, rotation, opt_anchor, opt_duration) { + goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); @@ -125,6 +130,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = if (goog.isDefAndNotNull(opt_anchor)) { var center = view.calculateCenterRotate(rotation, opt_anchor); map.withFrozenRendering(function() { + goog.asserts.assertInstanceof(view, ol.View2D); view.setCenter(center); view.setRotation(rotation); }); @@ -152,6 +158,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = */ ol.interaction.Interaction.zoom = function(map, view, resolution, opt_anchor, opt_duration, opt_direction) { + goog.asserts.assertInstanceof(view, ol.View2D); resolution = view.constrainResolution(resolution, 0, opt_direction); ol.interaction.Interaction.zoomWithoutConstraints( map, view, resolution, opt_anchor, opt_duration); @@ -167,6 +174,7 @@ ol.interaction.Interaction.zoom = */ ol.interaction.Interaction.zoomByDelta = function(map, view, delta, opt_anchor, opt_duration) { + goog.asserts.assertInstanceof(view, ol.View2D); var currentResolution = view.getResolution(); var resolution = view.constrainResolution(currentResolution, delta, 0); ol.interaction.Interaction.zoomWithoutConstraints( @@ -183,6 +191,7 @@ ol.interaction.Interaction.zoomByDelta = */ ol.interaction.Interaction.zoomWithoutConstraints = function(map, view, resolution, opt_anchor, opt_duration) { + goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); @@ -204,6 +213,7 @@ ol.interaction.Interaction.zoomWithoutConstraints = if (goog.isDefAndNotNull(opt_anchor)) { var center = view.calculateCenterZoom(resolution, opt_anchor); map.withFrozenRendering(function() { + goog.asserts.assertInstanceof(view, ol.View2D); view.setCenter(center); view.setResolution(resolution); });