[fusion-commits] r2605 - sandbox/ol212/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Sep 19 02:46:12 PDT 2012
Author: jng
Date: 2012-09-19 02:46:11 -0700 (Wed, 19 Sep 2012)
New Revision: 2605
Modified:
sandbox/ol212/lib/Map.js
Log:
Document the new client-zoom capabilities
Modified: sandbox/ol212/lib/Map.js
===================================================================
--- sandbox/ol212/lib/Map.js 2012-09-18 07:06:11 UTC (rev 2604)
+++ sandbox/ol212/lib/Map.js 2012-09-19 09:46:11 UTC (rev 2605)
@@ -168,7 +168,7 @@
/** flag to indicate if fractional zoom is supported, ie. allow any scale
* value rather than a fixed set of scales
*/
- fractionalZoom: true,
+ fractionalZoom: false,
/** The DOM object that holds the map */
maxScale: null, //set this to a large number in AppDef to zoom out beyond maxExtent, e.g. 1 billion
@@ -410,41 +410,69 @@
this.oMapOL.setBaseLayer(this.aMaps[0].oLayerOL);
}
- if (this.fractionalZoom) {
- var newResolutions = null;
- var mgResolutions = null;
- for (var i = 0; i < this.aMaps.length; i++) {
- if (this.aMaps[i].arch == 'MapGuide') {
- mgResolutions = this.aMaps[i].oLayerOL.resolutions;
- }
- }
- for (var i = 0; i < this.aMaps.length; i++) {
- if (this.aMaps[i].arch == 'Generic') {
- var oLayer = this.aMaps[i].oLayerOL;
- oLayer.serverResolutions = oLayer.resolutions;
- if (newResolutions == null) {
- newResolutions = [];
- for (var j = 0; j < oLayer.serverResolutions.length; j++) {
- newResolutions.push(oLayer.serverResolutions[j]);
- }
- for (var j = 0; j < mgResolutions.length; j++) {
- if (mgResolutions[j] < oLayer.minResolution) {
- newResolutions.push(mgResolutions[j]);
- }
- }
- }
- oLayer.resolutions = newResolutions;
- var newScales = [];
- for (var i = 0; i < newResolutions.length; i++) {
- newScales.push(OpenLayers.Util.getScaleFromResolution(newResolutions[i], oLayer.units));
- }
- oLayer.scales = newScales;
- oLayer.minResolution = newResolutions[newResolutions.length - 1];
- oLayer.maxScale = newScales[newScales.length - 1];
- oLayer.numZoomLevels = newScales.length;
- }
- }
+ //Take advantage of new client-zoom capabilities introduced in OpenLayers 2.12
+ //
+ //What we do here is for every grid-based commerical layer, we tack on extra resolutions
+ //of the MapGuide OL Layer that is below the minimum supported resolution of the commercial
+ //layers. The existing resolutions array is shifted to the layer's serverResolutions array.
+ //
+ //When we go below the minimum supported resolution of these commercial layers,
+ //client-zoom kicks in and stretches the commerical layers appropriately.
+ //
+ //A small side-effect is that if fractionalZoom = true, and the layer setup is such that
+ //this won't be set to false during initialization (eg. fractionalZoom = true +
+ //A MapGuide dynamic map + OSM layers), then the OSM layers will almost always be slightly
+ //stretched, as any zoom scale is allowed and OL will be stretching the OSM layers to match.
+ //
+ //This technique does not work with Google layers (as they aren't grid-based). The mere presence
+ //of Google layers (or any non-Grid layers) will disable client-zoom, and your map will be snapping
+ //to whatever discrete scale list that is imposed by the commercial layer
+ //
+ //With these changes the behaviour is like so (OSM is interchangeable with any other grid-based layer):
+ //
+ // - MapGuide + OSM (fractionalZoom = true): Fully dynamic map and OSM tiles are stretched accordingly. OSM
+ // tiles will most likely never be un-stretched due to the fully dynamic
+ // nature of the map.
+ // - MapGuide + OSM (fractionalZoom = false): Scales "snap" to OSM scales and are stretched accordingly
+ // when going below the minimum supported OSM scale
+ // - MapGuide + OSM + Explicit Scale List: Scales "snap" to OSM scales (any MG scales within the OSM scale
+ // list are disregarded). OSM tiles are stretched accordingly when
+ // going below the minimum supported OSM scale
+ //
+ //TODO: Yet to observe this behaviour with tiled MG maps or maps with tiled/untiled mixtures
+ var newResolutions = null;
+ var mgResolutions = null;
+ for (var i = 0; i < this.aMaps.length; i++) {
+ if (this.aMaps[i].arch == 'MapGuide') {
+ mgResolutions = this.aMaps[i].oLayerOL.resolutions;
+ }
}
+ for (var i = 0; i < this.aMaps.length; i++) {
+ if (this.aMaps[i].arch == 'Generic') {
+ var oLayer = this.aMaps[i].oLayerOL;
+ oLayer.serverResolutions = oLayer.resolutions;
+ if (newResolutions == null) {
+ newResolutions = [];
+ for (var j = 0; j < oLayer.serverResolutions.length; j++) {
+ newResolutions.push(oLayer.serverResolutions[j]);
+ }
+ for (var j = 0; j < mgResolutions.length; j++) {
+ if (mgResolutions[j] < oLayer.minResolution) {
+ newResolutions.push(mgResolutions[j]);
+ }
+ }
+ }
+ oLayer.resolutions = newResolutions;
+ var newScales = [];
+ for (var i = 0; i < newResolutions.length; i++) {
+ newScales.push(OpenLayers.Util.getScaleFromResolution(newResolutions[i], oLayer.units));
+ }
+ oLayer.scales = newScales;
+ oLayer.minResolution = newResolutions[newResolutions.length - 1];
+ oLayer.maxScale = newScales[newScales.length - 1];
+ oLayer.numZoomLevels = newScales.length;
+ }
+ }
var initialExtent = this.setInitialExtents();
this.setExtents(initialExtent);
More information about the fusion-commits
mailing list