[fusion-commits] r2606 - sandbox/ol212/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Sep 19 22:03:11 PDT 2012
Author: jng
Date: 2012-09-19 22:03:11 -0700 (Wed, 19 Sep 2012)
New Revision: 2606
Modified:
sandbox/ol212/lib/Map.js
Log:
Add more notes about the client-zoom capabilities and refine the capability check. Only apply client-zoom if the MapGuide Map Definition has no tiled layers (we may remove this requirement in the future as we continue to explore the client-zoom possibilities in Fusion)
Modified: sandbox/ol212/lib/Map.js
===================================================================
--- sandbox/ol212/lib/Map.js 2012-09-19 09:46:11 UTC (rev 2605)
+++ sandbox/ol212/lib/Map.js 2012-09-20 05:03:11 UTC (rev 2606)
@@ -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: false,
+ fractionalZoom: true,
/** 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,25 +410,26 @@
this.oMapOL.setBaseLayer(this.aMaps[0].oLayerOL);
}
- //Take advantage of new client-zoom capabilities introduced in OpenLayers 2.12
+ // 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.
+ // 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.
+ // 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.
+ // 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
+ // 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 if a non-Grid layer is the active
+ // one, 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):
+ // With these changes the behaviour is like so (OSM is interchangeable with any other grid-based layer, MapGuide
+ // is assumed to be fully dynamic and have no tiled layers):
//
// - 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
@@ -439,40 +440,58 @@
// 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
+ // MapGuide Map Definitions with tiled layers cannot take advantage of client-zoom (at least to my knowledge and for
+ // this initial implementation).
+ //
+ // So the same rules apply for MG tiled map integration: It must use the same scale list as Google + Bing + OSM.
+ //
+ // TODO: In the case of a mixed MG Map Definition and no CMS layers, investigate the possibility of using client-zoom
+ // so that MG tiled layers can be stretched.
var newResolutions = null;
var mgResolutions = null;
+ var bCanUseClientZoom = true;
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]);
- }
- }
+ if (this.aMaps[i].bSingleTile) {
+ bCanUseClientZoom = true;
+ } else {
+ //TODO: How smart can we be to make this be true?
+ bCanUseClientZoom = false;
}
- 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;
+ break;
}
}
+
+ //console.log("Can use client-zoom: " + bCanUseClientZoom);
+ if (bCanUseClientZoom) {
+ 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