[fusion-commits] r2203 - in trunk/layers: Generic MapServer
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Aug 16 13:13:15 EDT 2010
Author: madair
Date: 2010-08-16 17:13:15 +0000 (Mon, 16 Aug 2010)
New Revision: 2203
Modified:
trunk/layers/Generic/Generic.js
trunk/layers/MapServer/MapServer.js
Log:
closes #285: adding getLinkParams method to MapServer and Generic layers so that layer state (on/off) is preserved in the LinkToVIew widget
Modified: trunk/layers/Generic/Generic.js
===================================================================
--- trunk/layers/Generic/Generic.js 2010-08-12 18:18:11 UTC (rev 2202)
+++ trunk/layers/Generic/Generic.js 2010-08-16 17:13:15 UTC (rev 2203)
@@ -258,6 +258,13 @@
getSessionID: function() {
return '';
- }
+ },
+
+ getLinkParams: function() {
+ var queryParams = {};
+ queryParams.layerType = this.layerType; //need this? and one for this.mapTag.layerOptions.type?
+ return queryParams;
+ }
+
});
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2010-08-12 18:18:11 UTC (rev 2202)
+++ trunk/layers/MapServer/MapServer.js 2010-08-16 17:13:15 UTC (rev 2203)
@@ -174,12 +174,28 @@
mapSessionCreated: function() {
// restore the mapfile from a saved state.
- if(this.bRestoreMapState === true && this.oRestoredState.loadmap ){
+ if (this.bRestoreMapState === true && this.oRestoredState.loadmap ) {
this.loadMap(this.oRestoredState.loadmap);
+ } else if (this.sMapFile != '') {
+ var options = {};
+ if (this.bIsMapWidgetLayer) {
+ var showlayers = Fusion.getQueryParam('showlayers');
+ Fusion.queryParams['showlayers'] = null;
+ var hidelayers = Fusion.getQueryParam('hidelayers');
+ Fusion.queryParams['hidelayers'] = null;
+ var showgroups = Fusion.getQueryParam('showgroups');
+ Fusion.queryParams['showgroups'] = null;
+ var hidegroups = Fusion.getQueryParam('hidegroups');
+ Fusion.queryParams['hidegroups'] = null;
+ var options = {
+ showlayers: showlayers == '' ? [] : showlayers.split(','),
+ hidelayers: hidelayers == '' ? [] : hidelayers.split(','),
+ showgroups: showgroups == '' ? [] : showgroups.split(','),
+ hidegroups: hidegroups == '' ? [] : hidegroups.split(',')
+ };
+ }
+ this.loadMap(this.sMapFile, options);
}
- else if (this.sMapFile != '') {
- this.loadMap(this.sMapFile);
- }
window.setInterval(OpenLayers.Function.bind(this.pingServer, this),
this.keepAliveInterval * 1000);
},
@@ -215,8 +231,11 @@
options = options || {};
- this.aVisibleLayers = options.showlayers || [];
- this.aVisibleGroups = options.showgroups || [];
+ this.aShowLayers = options.showlayers || [];
+ this.aHideLayers = options.hidelayers || [];
+ this.aShowGroups = options.showgroups || [];
+ this.aHideGroups = options.showgroups || [];
+ this.aVisibleLayers = [];
this.aLayers = [];
this.oSelection = null;
@@ -273,8 +292,27 @@
var minScale = 1.0e10;
var maxScale = 0;
for (var i=0; i<this.aLayers.length; i++) {
+ var testLayer = this.aLayers[i].layerName;
if (this.aLayers[i].visible) {
- this.aVisibleLayers.push(this.aLayers[i].layerName);
+ var layerName = testLayer;
+ for (var j=0; j<this.aHideLayers.length; ++j) {
+ if (layerName == this.aHideLayers[j]) {
+ layerName = null;
+ this.aLayers[i].hide(true);
+ break;
+ }
+ }
+ if (layerName) this.aVisibleLayers.push(layerName);
+ } else {
+ var layerName = null;
+ for (var j=0; j<this.aShowLayers.length; ++j) {
+ if (testLayer == this.aShowLayers[j]) {
+ layerName = testLayer;
+ this.aLayers[i].show(true);
+ break;
+ }
+ }
+ if (layerName) this.aVisibleLayers.push(layerName);
}
minScale = Math.min(minScale, this.aLayers[i].minScale);
maxScale = Math.max(maxScale, this.aLayers[i].maxScale);
@@ -529,19 +567,23 @@
this.oLayerOL.mergeNewParams(params);
},
- showLayer: function( sLayer ) {
+ showLayer: function( sLayer, noDraw ) {
this.aVisibleLayers.push(sLayer.layerName);
- this.drawMap();
+ if (!noDraw) {
+ this.drawMap();
+ }
},
- hideLayer: function( sLayer ) {
+ hideLayer: function( sLayer, noDraw ) {
for (var i=0; i<this.aLayers.length; i++) {
if (this.aVisibleLayers[i] == sLayer.layerName) {
this.aVisibleLayers.splice(i,1);
break;
}
}
- this.drawMap();
+ if (!noDraw) {
+ this.drawMap();
+ }
},
showGroup: function( group, noDraw ) {
@@ -859,6 +901,43 @@
return url + '?'+params;
},
+ getLinkParams: function() {
+ var queryParams = {};
+ queryParams.theme = this.sMapResourceId;
+
+ //determine which layers have been toggled
+ var showLayers = [];
+ var hideLayers = [];
+ for (var i=0; i<this.aLayers.length; ++i) {
+ var layer = this.aLayers[i];
+ if (layer.visible && !layer.initiallyVisible) { //layer was turned on
+ showLayers.push(layer.layerName);
+ }
+ if (!layer.visible && layer.initiallyVisible) { //layer was turned off
+ hideLayers.push(layer.layerName);
+ }
+ }
+ queryParams.showlayers = showLayers.join(',');
+ queryParams.hidelayers = hideLayers.join(',');
+
+ //determine which groups have been toggled
+ var showGroups = [];
+ var hideGroups = [];
+ for (var i=0; i<this.layerRoot.groups.length; ++i) {
+ var group = this.layerRoot.groups[i];
+ if (group.visible && !group.initiallyVisible) { //layer was turned on
+ showGroups.push(group.groupName);
+ }
+ if (!group.visible && group.initiallyVisible) { //layer was turned off
+ hideGroups.push(group.groupName);
+ }
+ }
+ queryParams.showgroups = showGroups.join(',');
+ queryParams.hidegroups = hideGroups.join(',');
+
+ return queryParams;
+ },
+
getMapTip: function(oMapTips){
if(this.bMapTipFired == false){
//console.log("MAPSERVER:getMapTip");
More information about the fusion-commits
mailing list