[fusion-commits] r1232 - in trunk: MapGuide lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Mar 10 13:07:46 EDT 2008
Author: pagameba
Date: 2008-03-10 13:07:46 -0400 (Mon, 10 Mar 2008)
New Revision: 1232
Modified:
trunk/MapGuide/MapGuide.js
trunk/lib/ApplicationDefinition.js
Log:
Re #20. Adding support for processing both layer and group events that can target either layers or groups.
Modified: trunk/MapGuide/MapGuide.js
===================================================================
--- trunk/MapGuide/MapGuide.js 2008-03-10 16:55:37 UTC (rev 1231)
+++ trunk/MapGuide/MapGuide.js 2008-03-10 17:07:46 UTC (rev 1232)
@@ -799,56 +799,103 @@
Fusion.ajaxRequest(loadmapScript, options);
},
- showLayer: function( layer ) {
- if (this.mapInfo && this.mapInfo.layerEvents[layer.layerName]) {
- var layerEvent = this.mapInfo.layerEvents[layer.layerName];
- for (var i=0; i<layerEvent.onEnable.length; i++) {
- var l = this.layerRoot.findLayer(layerEvent.onEnable[i].name);
- if (l) {
- if (layerEvent.onEnable[i].enable) {
- l.show();
- } else {
- l.hide();
+ processLayerEvents: function(layer, isEnabling) {
+ if (this.mapInfo && this.mapInfo.mapEvents.layerEvents[layer.layerName]) {
+ var layerEvent = this.mapInfo.mapEvents.layerEvents[layer.layerName];
+ var events = isEnabling ? layerEvent.onEnable : layerEvent.onDisable;
+ for (var i=0; i<events.length; i++) {
+ var o = events[i];
+ if (o.type == 'layer') {
+ var l = this.layerRoot.findLayer(o.name);
+ if (l) {
+ if (events[i].enable) {
+ l.show(true);
+ } else {
+ l.hide(true);
+ }
}
+
+ } else if (o.type == 'group') {
+ var g = this.layerRoot.findGroupByAtribute('groupName', o.name);
+ if (g) {
+ if (events.enable) {
+ g.show(true);
+ } else {
+ g.hide(true);
+ }
+ }
}
}
}
- this.aShowLayers.push(layer.uniqueId);
- this.drawMap();
},
- hideLayer: function( layer ) {
- if (this.mapInfo && this.mapInfo.layerEvents[layer.layerName]) {
- var layerEvent = this.mapInfo.layerEvents[layer.layerName];
- for (var i=0; i<layerEvent.onDisable.length; i++) {
- var l = this.layerRoot.findLayer(layerEvent.onDisable[i].name);
- if (l) {
- if (layerEvent.onDisable[i].enable) {
- l.show();
- } else {
- l.hide();
+ processGroupEvents: function(group, isEnabling) {
+ if (this.mapInfo && this.mapInfo.mapEvents.groupEvents[group.groupName]) {
+ var groupEvent = this.mapInfo.mapEvents.groupEvents[group.groupName];
+ var events = isEnabling ? groupEvent.onEnable : groupEvent.onDisable;
+ for (var i=0; i<events.length; i++) {
+ var o = events[i];
+ if (o.type == 'layer') {
+ var l = this.layerRoot.findLayer(o.name);
+ if (l) {
+ if (events[i].enable) {
+ l.show(true);
+ } else {
+ l.hide(true);
+ }
}
+
+ } else if (o.type == 'group') {
+ var g = this.layerRoot.findGroupByAtribute('groupName', o.name);
+ if (g) {
+ if (events.enable) {
+ g.show(true);
+ } else {
+ g.hide(true);
+ }
+ }
}
}
- }
+ }
+ },
+
+ showLayer: function( layer, noDraw ) {
+ this.processLayerEvents(layer, true);
+ this.aShowLayers.push(layer.uniqueId);
+ if (!noDraw) {
+ this.drawMap();
+ }
+ },
+
+ hideLayer: function( layer, noDraw ) {
+ this.processLayerEvents(layer, false);
this.aHideLayers.push(layer.uniqueId);
- this.drawMap();
+ if (!noDraw) {
+ this.drawMap();
+ }
},
- showGroup: function( group ) {
- if (group.groupName == 'layerRoot') {
- this.oLayerOL.setVisibility(true);
- } else {
- this.aShowGroups.push(group.uniqueId);
- this.drawMap();
- }
+
+ showGroup: function( group, noDraw ) {
+ this.processGroupEvents(group, true);
+ if (group.groupName == 'layerRoot') {
+ this.oLayerOL.setVisibility(true);
+ } else {
+ this.aShowGroups.push(group.uniqueId);
+ if (!noDraw) {
+ this.drawMap();
+ }
+ }
},
- hideGroup: function( group ) {
- if (group.groupName == 'layerRoot') {
- this.oLayerOL.setVisibility(false);
- } else {
- this.aHideGroups.push(group.uniqueId);
- this.drawMap();
- }
+ hideGroup: function( group, noDraw ) {
+ this.processGroupEvents(group, false);
+ if (group.groupName == 'layerRoot') {
+ this.oLayerOL.setVisibility(false);
+ } else {
+ this.aHideGroups.push(group.uniqueId);
+ if (!noDraw) {
+ this.drawMap();
+ }
+ }
},
refreshLayer: function( layer ) {
this.aRefreshLayers.push(layer.uniqueId);
@@ -921,22 +968,22 @@
this.actuallyVisible = o.actuallyVisible;
},
- show: function() {
+ show: function(noDraw) {
if (this.visible) {
return;
}
- this.oMap.showGroup(this);
+ this.oMap.showGroup(this, noDraw ? true : false);
this.visible = true;
if (this.legend && this.legend.checkBox) {
this.legend.checkBox.checked = true;
}
},
- hide: function() {
+ hide: function(nodraw) {
if (!this.visible) {
return;
}
- this.oMap.hideGroup(this);
+ this.oMap.hideGroup(this, noDraw ? true : false);
this.visible = false;
if (this.legend && this.legend.checkBox) {
this.legend.checkBox.checked = false;
@@ -1016,22 +1063,22 @@
return null;
},
- show: function() {
+ show: function(noDraw) {
if (this.visible) {
return;
}
- this.oMap.showLayer(this);
+ this.oMap.showLayer(this, noDraw ? true : false);
this.set('visible', true);
if (this.legend && this.legend.checkBox) {
this.legend.checkBox.checked = true;
}
},
- hide: function() {
+ hide: function(noDraw) {
if (!this.visible) {
return;
}
- this.oMap.hideLayer(this);
+ this.oMap.hideLayer(this, noDraw ? true : false);
this.set('visible',false);
if (this.legend && this.legend.checkBox) {
this.legend.checkBox.checked = false;
Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js 2008-03-10 16:55:37 UTC (rev 1231)
+++ trunk/lib/ApplicationDefinition.js 2008-03-10 17:07:46 UTC (rev 1232)
@@ -419,7 +419,7 @@
for (var i=0; i<jsonNode.Map.length; i++) {
var map = new Fusion.Lib.ApplicationDefinition.Map(jsonNode.Map[i]);
var links = {groups:[], layers:[]};
- var layerEvents = {};
+ var mapevents = {layerEvents:{},groupEvents:{}};
if (jsonNode.Map[i].Extension) {
var extension = jsonNode.Map[i].Extension[0];
if (extension.Links) {
@@ -439,33 +439,42 @@
}
/* process layer events */
//TODO: Should this be called MapEvents?
- if (extension.LayerEvents) {
- if (extension.LayerEvents[0].Layer instanceof Array) {
- for (var j=0; j<extension.LayerEvents[0].Layer.length; j++) {
- var layer = extension.LayerEvents[0].Layer[j];
+ if (extension.MapEvents) {
+ if (extension.MapEvents[0].Layer instanceof Array) {
+ for (var j=0; j<extension.MapEvents[0].Layer.length; j++) {
+ var layer = extension.MapEvents[0].Layer[j];
var layerObj = {};
layerObj.name = layer.Name[0];
layerObj.onEnable = [];
+ if (layer.OnEnable instanceof Array) {
+ layerObj.onEnable = this.parseMapEventSubBlock(layer.onEnable[0]);
+ }
layerObj.onDisable = [];
-
+ if (layer.OnDisable instanceof Array) {
+ layerObj.onDisable = this.parseMapEventSubBlock(layer.onDisable[0]);
+ }
+ mapEvents.layerEvents[layerObj.name] = layerObj;
+ }
+ }
+ if (extension.MapEvents[0].Group instanceof Array) {
+ for (var j=0; j<extension.MapEvents[0].Group.length; j++) {
+ var group = extension.MapEvents[0].Group[j];
+ var groupObj = {};
+ groupObj.name = group.Name[0];
+ groupObj.onEnable = [];
if (layer.OnEnable instanceof Array) {
- for (var k=0; k<layer.OnEnable[0].Layer.length; k++) {
- var kLayer = layer.OnEnable[0].Layer[k];
- layerObj.onEnable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
- }
+ groupObj.onEnable = this.parseMapEventSubBlock(group.onEnable[0]);
}
+ groupObj.onDisable = [];
if (layer.OnDisable instanceof Array) {
- for (var k=0; k<layer.OnDisable[0].Layer.length; k++) {
- var kLayer = layer.OnDisable[0].Layer[k];
- layerObj.onDisable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
- }
+ groupObj.onDisable = this.parseMapEventSubBlock(group.onDisable[0]);
}
- layerEvents[layerObj.name] = layerObj;
+ mapEvents.groupEvents[groupObj.name] = groupObj;
}
}
}
}
- map.mapInfo = {links: links, layerEvents: layerEvents};
+ map.mapInfo = {links: links, mapEvents: mapEvents};
this.maps.push(map);
}
} else {
@@ -473,6 +482,23 @@
}
},
+ parseMapEventSubBlock: function(block) {
+ var a = [];
+ if (block.Layer) {
+ for (var i=0; i<block.Layer.length; i++) {
+ var layer = block.Layer[i];
+ a.push({type: 'layer', name:layer.Name[0], enable: layer.Enable[0] == 'true' ? true : false});
+ }
+ }
+ if (block.Group && block.Group instanceof Array) {
+ for (var i=0; i<block.Group.length; i++) {
+ var layer = block.Group[i];
+ a.push({type: 'group', name:group.Name[0], enable: group.Enable[0] == 'true' ? true : false});
+ }
+ }
+ return a;
+ },
+
getInitialView: function() {
return this.initialView;
},
More information about the fusion-commits
mailing list