[OpenLayers-Commits] r3145 - sandbox/tschaub/google/lib/OpenLayers/Layer
commits at openlayers.org
commits at openlayers.org
Wed May 9 21:45:14 EDT 2007
Author: tschaub
Date: 2007-05-09 21:45:14 -0400 (Wed, 09 May 2007)
New Revision: 3145
Modified:
sandbox/tschaub/google/lib/OpenLayers/Layer/GoogleMercator.js
Log:
Give the layer it's own getZoomForResolution - because we're dealing with floating point imprecision in the coordinate transforms and (artifically) high decimal precision the calculated resolutions, the smallest resolution larger than the input rule is too strict for this layer - look for smallest difference instead
Modified: sandbox/tschaub/google/lib/OpenLayers/Layer/GoogleMercator.js
===================================================================
--- sandbox/tschaub/google/lib/OpenLayers/Layer/GoogleMercator.js 2007-05-10 00:52:43 UTC (rev 3144)
+++ sandbox/tschaub/google/lib/OpenLayers/Layer/GoogleMercator.js 2007-05-10 01:45:14 UTC (rev 3145)
@@ -90,7 +90,33 @@
return moBounds;
},
+ /**
+ * Return the closest zoom level for the given resolution. Since we're
+ * dealing with precision issues, this really returns the closest zoom level
+ * instead of the index of the smallest resolution larger than the one
+ * passed in (as with the super-class). If this method is not overridden
+ * here - things get real messy when switching base layers at small
+ * resolutions far from the origin.
+ *
+ * @param {float} resolution
+ * @returns A suitable zoom level for the specified resolution.
+ * @type int
+ */
+ getZoomForResolution: function(resolution) {
+ var diff;
+ var closestZoom = 0;
+ var minDiff = Number.POSITIVE_INFINITY;
+ for(var i=0; i<this.resolutions.length; ++i) {
+ diff = Math.abs(this.resolutions[i] - resolution);
+ if(diff < minDiff) {
+ closestZoom = i;
+ minDiff = diff;
+ }
+ }
+ return closestZoom;
+ },
+
/************************************
* *
* MapObject Primitives *
More information about the Commits
mailing list