From a1a1128ac7097009fb33fe7e75d64d43bf15d05d Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 5 Oct 2006 17:07:15 +0000 Subject: [PATCH] for fixed zoom layers, be careful that if the 3rd party tool is not loaded, they wont be able to return a valid getExtent() and therefore neither a valid getResolution(). Make sure those return null without crashing. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1597 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/FixedZoomLevels.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/FixedZoomLevels.js b/lib/OpenLayers/Layer/FixedZoomLevels.js index 6d08cf4bd4..7907d34aea 100644 --- a/lib/OpenLayers/Layer/FixedZoomLevels.js +++ b/lib/OpenLayers/Layer/FixedZoomLevels.js @@ -77,12 +77,18 @@ OpenLayers.Layer.FixedZoomLevels.prototype = { * @type float */ getResolution: function() { + var resolution = null; + var viewSize = this.map.getSize(); var extent = this.getExtent(); - return Math.max( extent.getWidth() / viewSize.w, - extent.getHeight() / viewSize.h ); - }, - + + if ((viewSize != null) && (extent != null)) { + resolution = Math.max( extent.getWidth() / viewSize.w, + extent.getHeight() / viewSize.h ); + } + return resolution; + }, + /** Calculates using px-> lonlat translation functions on tl and br * corners of viewport *