[fusion-commits] r1662 - in trunk: MapServer lib
templates/mapserver/standard
templates/mapserver/standard/themes/delicious widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Nov 12 16:10:10 EST 2008
Author: madair
Date: 2008-11-12 16:10:10 -0500 (Wed, 12 Nov 2008)
New Revision: 1662
Modified:
trunk/MapServer/MapServer.js
trunk/lib/ApplicationDefinition.js
trunk/lib/Map.js
trunk/templates/mapserver/standard/ApplicationDefinition.xml
trunk/templates/mapserver/standard/index.html
trunk/templates/mapserver/standard/themes/delicious/jxtheme.uncompressed.css
trunk/widgets/Legend.js
trunk/widgets/Navigator.js
trunk/widgets/OverviewMap.js
trunk/widgets/SelectionInfo.js
Log:
re #140: further changes to support multiple layer types
Modified: trunk/MapServer/MapServer.js
===================================================================
--- trunk/MapServer/MapServer.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/MapServer/MapServer.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -1,5 +1,5 @@
/**
- * Fusion.Maps.MapServer
+ * Fusion.Layers.MapServer
*
* $Id$
*
@@ -24,28 +24,19 @@
*/
/******************************************************************************
- * Class: Fusion.Maps.MapServer
+ * Class: Fusion.Layers.MapServer
*
* Implementation of the map widget for MapServer CGI interface services
*/
Fusion.Event.MAP_LAYER_ORDER_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Maps.MapServer = OpenLayers.Class(Fusion.Lib.EventMgr, {
+Fusion.Layers.MapServer = OpenLayers.Class(Fusion.Layers, {
arch: 'MapServer',
session: [null],
- aShowLayers: null,
- aHideLayers: null,
- aShowGroups: null,
- aHideGroups: null,
- aRefreshLayers: null,
sActiveLayer: null,
selectionType: 'INTERSECTS',
bSelectionOn: false,
- bDisplayInLegend: true, //TODO: set this in AppDef?
- bExpandInLegend: true, //TODO: set this in AppDef?
oSelection: null,
- bMapLoaded : false,
- bIsMapWidgetLayer : true, //Setthis to false for overview map layers
bLayersReversed: true, //MS returns layers bottom-most layer first, we treat layer order in reverse sense
mapMetadataKeys: null,
layerMetadataKeys: null,
@@ -53,36 +44,18 @@
//the map file
sMapFile: null,
- //imagetype
- _sImageType : 'png',
-
- initialize : function(map, mapTag, isMapWidgetLayer) {
- //console.log('Fusion.Maps.MapServer.initialize');
- /*
- //Object.inheritFrom(this, Fusion.Lib.EventMgr, []);
-
- prototype is not yet defined when this is called now omitting.
-
- Fusion.Lib.EventMgr.prototype.initialize.apply(this, []);
- */
-
+ initialize: function(map, mapTag, isMapWidgetLayer) {
+ //console.log('Fusion.Layers.MapServer.initialize');
+ Fusion.Layers.prototype.initialize.apply(this, arguments);
this.registerEventID(Fusion.Event.MAP_SESSION_CREATED);
- this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
- this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
- this.registerEventID(Fusion.Event.MAP_LOADED);
- this.registerEventID(Fusion.Event.MAP_LOADING);
- this.registerEventID(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
-
- this.mapWidget = map;
- this.oSelection = null;
- if (isMapWidgetLayer != null) {
- this.bIsMapWidgetLayer = isMapWidgetLayer;
- }
-
- var extension = mapTag.extension;
- this.ratio = extension.MapRatio ? extension.MapRatio[0] : '1.0';
+
//this.selectionType = extension.SelectionType ? extension.SelectionType[0] : 'INTERSECTS';
+ this.sMapFile = mapTag.extension.MapFile ? mapTag.extension.MapFile[0] : '';
+
+ this.mapMetadataKeys = mapTag.extension.MapMetadata ? mapTag.extension.MapMetadata[0] : null;
+ this.layerMetadataKeys = mapTag.extension.LayerMetadata ? mapTag.extension.LayerMetadata[0] : null;
+
rootOpts = {
displayInLegend: this.bDisplayInLegend,
expandInLegend: this.bExpandInLegend,
@@ -93,17 +66,10 @@
actuallyVisible: true
//TODO: set other opts for group initialization as required
};
- this.layerRoot = new Fusion.Maps.MapServer.Group(rootOpts,this);
+ this.layerRoot = new Fusion.Layers.Group(rootOpts,this);
- this.sMapFile = extension.MapFile ? extension.MapFile[0] : '';
+ this.keepAliveInterval = parseInt(mapTag.extension.KeepAliveInterval ? mapTag.extension.KeepAliveInterval[0] : 300);
- this.mapMetadataKeys = extension.MapMetadata ? extension.MapMetadata[0] : null;
- this.layerMetadataKeys = extension.LayerMetadata ? extension.LayerMetadata[0] : null;
-
- this.bSingleTile = mapTag.singleTile;// this is set by the AppDef.Map object
-
- this.keepAliveInterval = parseInt(extension.KeepAliveInterval ? extension.KeepAliveInterval[0] : 300);
-
if (mapTag.sid) {
this.session[0] = mapTag.sid;
this.mapSessionCreated();
@@ -120,7 +86,7 @@
var options = {onSuccess: OpenLayers.Function.bind(this.createSessionCB, this)};
Fusion.ajaxRequest(scriptURL,options);
}
- if (this.session[0] instanceof Fusion.Maps.MapServer) {
+ if (this.session[0] instanceof Fusion.Layers.MapServer) {
this.session[0].registerForEvent(Fusion.Event.MAP_SESSION_CREATED,
OpenLayers.Function.bind(this.mapSessionCreated, this));
} else {
@@ -128,7 +94,7 @@
}
},
- createSessionCB : function(r) {
+ createSessionCB: function(r) {
if (r.status == 200) {
var o;
eval('o='+r.responseText);
@@ -153,14 +119,6 @@
return this.session[0];
},
- getMapName: function() {
- return this._sMapname;
- },
-
- getMapTitle: function() {
- return this._sMapTitle;
- },
-
loadMap: function(mapfile, options) {
while (this.mapWidget.isBusy()) {
this.mapWidget._removeWorker();
@@ -176,12 +134,7 @@
this.sMapFile = mapfile;
return;
}
-
- if (this.bIsMapWidgetLayer) {
- this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADING);
- } else {
- this.triggerEvent(Fusion.Event.MAP_LOADING);
- }
+ this.triggerEvent(Fusion.Event.LAYER_LOADING);
this.mapWidget._addWorker();
this._fScale = -1;
@@ -189,7 +142,6 @@
options = options || {};
- this._oMaxExtent = null;
this.aVisibleLayers = options.showlayers || [];
this.aVisibleGroups = options.showgroups || [];
this.aLayers = [];
@@ -226,7 +178,7 @@
this._sImageType = o.imagetype;
this.metadata = o.metadata;
- this._oMaxExtent = OpenLayers.Bounds.fromArray(o.extent);
+ this.mapTag.layerOptions.maxExtent = OpenLayers.Bounds.fromArray(o.extent);
this.layerRoot.clear();
this.layerRoot.legendLabel = this._sMapTitle;
@@ -239,8 +191,8 @@
if (this.aLayers[i].visible) {
this.aVisibleLayers.push(this.aLayers[i].layerName);
}
- minScale = Math.min(minScale, this.aLayers[i].minScale);
- maxScale = Math.max(maxScale, this.aLayers[i].maxScale);
+ minScale = Math.min(minScale, this.aLayers[i].minScale);
+ maxScale = Math.max(maxScale, this.aLayers[i].maxScale);
}
//a scale value of 0 is undefined
if (minScale <= 0) {
@@ -258,19 +210,20 @@
singleTile: true,
ratio: this.ratio,
units: this.units,
- maxExtent : this._oMaxExtent,
- maxResolution : 'auto',
- minScale : maxScale, //OL interpretation of min/max scale is reversed from Fusion
- maxScale : minScale
+ maxResolution: 'auto',
+ minScale: maxScale, //OL interpretation of min/max scale is reversed from Fusion
+ maxScale: minScale
};
+ OpenLayers.Util.extend(layerOptions, this.mapTag.layerOptions);
//create the OL layer for this Map layer
var params = {
layers: this.aVisibleLayers.join(' '),
- session : this.getSessionID(),
- map : this._sMapFile,
- map_imagetype : this._sImageType
+ session: this.getSessionID(),
+ map: this._sMapFile,
+ map_imagetype: this.sImageType
};
+ OpenLayers.Util.extend(params, this.mapTag.layerParams);
//remove this layer if it was already loaded
if (this.oLayerOL) {
@@ -288,13 +241,7 @@
if (this.bIsMapWidgetLayer) {
this.mapWidget.addMap(this);
- this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
this.mapWidget.oMapOL.units = this.oLayerOL.units;
- var initialExtent = this.mapWidget.setInitialExtents();
- this.mapWidget.setExtents(initialExtent);
- this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADED);
- } else {
- this.triggerEvent(Fusion.Event.MAP_LOADED);
}
this.bMapLoaded = true;
@@ -305,6 +252,7 @@
'Failed to load requested map:\n'+r.responseText));
}
this.mapWidget._removeWorker();
+ this.triggerEvent(Fusion.Event.LAYER_LOADED);
},
reloadMap: function() {
@@ -371,7 +319,7 @@
oLayer.scaleRanges = [];
for (var j=0; j<o.layers[i].scaleRanges.length; j++)
{
- var scaleRange = new Fusion.Maps.MapServer.ScaleRange(o.layers[i].scaleRanges[j],
+ var scaleRange = new Fusion.Layers.ScaleRange(o.layers[i].scaleRanges[j],
oLayer.layerType);
oLayer.scaleRanges.push(scaleRange);
}
@@ -448,7 +396,7 @@
parseMapLayersAndGroups: function(o) {
for (var i=0; i<o.groups.length; i++) {
- var group = new Fusion.Maps.MapServer.Group(o.groups[i], this);
+ var group = new Fusion.Layers.Group(o.groups[i], this);
var parent;
if (group.parentUniqueId != '') {
parent = this.layerRoot.findGroup(group.parentUniqueId);
@@ -459,7 +407,7 @@
}
for (var i=0; i<o.layers.length; i++) {
- var layer = new Fusion.Maps.MapServer.Layer(o.layers[i], this);
+ var layer = new Fusion.Layers.Layer(o.layers[i], this);
var parent;
if (layer.parentGroup != '') {
parent = this.layerRoot.findGroup(layer.parentGroup);
@@ -471,17 +419,7 @@
}
},
-
- /**
- * Function: isMapLoaded
- *
- * Returns true if the Map has been laoded succesfully form the server
- */
- isMapLoaded: function() {
- return this.bMapLoaded;
- },
-
- getScale : function() {
+ getScale: function() {
return this.mapWidget.getScale();
},
@@ -512,13 +450,13 @@
},
showLayer: function( sLayer ) {
- this.aVisibleLayers.push(sLayer);
+ this.aVisibleLayers.push(sLayer.layerName);
this.drawMap();
},
hideLayer: function( sLayer ) {
for (var i=0; i<this.aLayers.length; i++) {
- if (this.aVisibleLayers[i] == sLayer) {
+ if (this.aVisibleLayers[i] == sLayer.layerName) {
this.aVisibleLayers.splice(i,1);
break;
}
@@ -526,7 +464,29 @@
this.drawMap();
},
- showGroup: function( sGroup ) {
+ 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, noDraw ) {
+ this.processGroupEvents(group, false);
+ if (group.groupName == 'layerRoot') {
+ this.oLayerOL.setVisibility(false);
+ } else {
+ this.aHideGroups.push(group.uniqueId);
+ if (!noDraw) {
+ this.drawMap();
+ }
+ }
+ },
+ showGroupOLD: function( sGroup ) {
if (sGroup == 'layerRoot') {
this.oLayerOL.setVisibility(true);
} else {
@@ -541,7 +501,7 @@
}
},
- hideGroup: function( sGroup ) {
+ hideGroupOLD: function( sGroup ) {
if (sGroup == 'layerRoot') {
this.oLayerOL.setVisibility(false);
} else {
@@ -567,7 +527,7 @@
hasSelection: function() { return this.bSelectionOn; },
- getSelectionCB : function(userFunc, layers, startend, r) {
+ getSelectionCB: function(userFunc, layers, startend, r) {
if (r.status == 200)
{
var o;
@@ -591,7 +551,7 @@
/**
* Returns the number of features selected for this map layer
*/
- getSelectedFeatureCount : function() {
+ getSelectedFeatureCount: function() {
var total = 0;
for (var j=0; j<this.aLayers.length; ++j) {
total += this.aLayers[j].selectedFeatureCount;
@@ -602,7 +562,7 @@
/**
* Returns the number of features selected for this map layer
*/
- getSelectedLayers : function() {
+ getSelectedLayers: function() {
var layers = [];
for (var j=0; j<this.aLayers.length; ++j) {
if (this.aLayers[j].selectedFeatureCount>0) {
@@ -615,7 +575,7 @@
/**
* Returns the number of features selected for this map layer
*/
- getSelectableLayers : function() {
+ getSelectableLayers: function() {
var layers = [];
for (var j=0; j<this.aLayers.length; ++j) {
if (this.aLayers[j].selectable) {
@@ -644,7 +604,7 @@
* six elements for layer 2 starting at index 6). If it is not
* given, all the elemsnts will be returned.
*/
- getSelection : function(userFunc, layers, startcount) {
+ getSelection: function(userFunc, layers, startcount) {
if (userFunc)
{
@@ -668,7 +628,7 @@
/**
Utility function to clear current selection
*/
- clearSelection : function() {
+ clearSelection: function() {
if (!this.aLayers) return;
//clear the selection count for the layers
@@ -687,7 +647,7 @@
/**
Call back function when slect functions are called (eg queryRect)
*/
- processQueryResults : function(zoomTo, r) {
+ processQueryResults: function(zoomTo, r) {
this.mapWidget._removeWorker();
if (r.status == 200) {
var o;
@@ -717,7 +677,7 @@
/**
Do a query on the map
*/
- query : function(options) {
+ query: function(options) {
this.mapWidget._addWorker();
//clear the selection count for the layers
@@ -759,14 +719,6 @@
Fusion.ajaxRequest(queryScript, ajaxOptions);
},
- loadStart: function() {
- this.mapWidget._addWorker();
- },
-
- loadEnd: function() {
- this.mapWidget._removeWorker();
- },
-
pingServer: function() {
var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
var params = {};
@@ -782,7 +734,7 @@
return null;
},
- getLayerById : function(id)
+ getLayerById: function(id)
{
var oLayer = null;
for (var i=0; i<this.aLayers.length; i++)
@@ -802,216 +754,23 @@
} else {
return '';
}
- }
+ },
-});
-
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.Group
- *
- * Implements the map layer groups for MapServer CGI services
-*/
-
-Fusion.Maps.MapServer.Group = OpenLayers.Class(Fusion.Widget.Map.Group, {
- oMap: null,
- initialize: function(o, oMap) {
- this.uniqueId = o.uniqueId;
- Fusion.Widget.Map.Group.prototype.initialize.apply(this, [o.groupName]);
- this.oMap = oMap;
- this.groupName = o.groupName;
- this.legendLabel = o.legendLabel;
- this.parentUniqueId = o.parentUniqueId;
- this.groupType = o.groupType;
- this.displayInLegend = o.displayInLegend;
- this.expandInLegend = o.expandInLegend;
- this.visible = o.visible;
- this.actuallyVisible = o.actuallyVisible;
- },
-
- clear: function() {
- Fusion.Widget.Map.Group.prototype.clear.apply(this, []);
- //this.oMap = null;
- },
-
- show: function() {
- this.visible = true;
- this.oMap.showGroup(this.groupName);
- },
-
- hide: function() {
- this.visible = false;
- this.oMap.hideGroup(this.groupName);
- },
-
- isVisible: function() {
- var bParentVisible = (this.parentGroup && this.parentGroup.isVisible) ? this.parentGroup.isVisible() : true;
- return this.visible && bParentVisible;
+ getLegendImageURL: function(fScale, layer) {
+ var sl = Fusion.getScriptLanguage();
+ var url = Fusion.getFusionURL() + '/' + this.arch + '/' + sl + '/LegendIcon.' + sl;
+ var sessionid = this.getSessionID();
+ var params = 'mapname='+this._sMapname+"&session="+sessionid + '&layername='+layer.resourceId + '&classindex='+this.index;
+ return url + '?'+params;
}
});
+
var MSLAYER_POINT_TYPE = 0;
var MSLAYER_LINE_TYPE = 1;
var MSLAYER_POLYGON_TYPE = 2;
var MSLAYER_SOLID_TYPE = 3;
var MSLAYER_RASTER_TYPE = 4;
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.Layer
- *
-* Implements individual map legend layers for MapServer services
-*/
-Fusion.Maps.MapServer.Layer = OpenLayers.Class(Fusion.Widget.Map.Group, {
-
- scaleRanges: null,
-
- oMap: null,
-
- initialize: function(o, oMap) {
- this.uniqueId = o.uniqueId;
- Fusion.Widget.Map.Layer.prototype.initialize.apply(this, [this.uniqueId]);
- this.oMap = oMap;
- this.layerName = o.layerName;
- this.uniqueId = o.uniqueId;
- this.resourceId = o.resourceId;
- this.legendLabel = o.legendLabel;
- this.selectable = o.selectable;
- this.selectedFeatureCount = 0;
- this.layerTypes = [].concat(o.layerTypes);
- this.displayInLegend = o.displayInLegend;
- this.expandInLegend = o.expandInLegend;
- this.visible = o.visible;
- this.actuallyVisible = o.actuallyVisible;
- this.editable = o.editable;
- this.parentGroup = o.parentGroup;
- this.metadata = o.metadata;
- this.extent = o.extent;
- this.scaleRanges = [];
- this.minScale = o.minScale;
- this.maxScale = o.maxScale;
-
- /*
- for (var i=0; i<o.scaleRanges.length; i++) {
- var scaleRange = new Fusion.Maps.MapServer.ScaleRange(o.scaleRanges[i], this.supportsType(4));
- this.scaleRanges.push(scaleRange);
- this.minScale = Math.min(this.minScale, scaleRange.minScale);
- this.maxScale = Math.max(this.maxScale, scaleRange.maxScale);
-
- }
- */
- },
-
- clear: function() {
- Fusion.Widget.Map.Layer.prototype.clear.apply(this, []);
- this.oMap = null;
- this.legend = null;
- },
-
- supportsType: function(type) {
- for (var i=0; i<this.layerTypes.length; i++) {
- if (this.layerTypes[i] == type) {
- return true;
- }
- }
- return false;
- },
-
- getScaleRange: function(fScale) {
- for (var i=0; i<this.scaleRanges.length; i++) {
- if (this.scaleRanges[i].contains(fScale)) {
- return this.scaleRanges[i];
- }
- }
- return null;
- },
-
- show: function() {
- this.set('visible', true);
- this.oMap.showLayer(this.layerName);
- },
-
- hide: function() {
- this.set('visible',false);
- this.oMap.hideLayer(this.layerName);
- },
-
- isVisible: function() {
- var bParentVisible = this.parentGroup ? this.parentGroup.isVisible() : true;
- return this.visible && bParentVisible;
- },
-
- getMetadata: function(key) {
- if (typeof this.metadata[key] != 'undefined') {
- return this.metadata[key];
- } else {
- return '';
- }
- }
-});
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.ScaleRange
- *
-* Implements a scale range object for MapServer services
-*/
-
-Fusion.Maps.MapServer.ScaleRange = OpenLayers.Class({
- styles: null,
- initialize: function(o, bRaster) {
- this.minScale = o.minScale;
- this.maxScale = o.maxScale;
- this.styles = [];
- if (!o.styles) {
- return;
- }
-
- /*special case : if there are no classes and it is a raster layer
- we set it to use the default static raster icon*/
- if (o.styles.length == 0 && bRaster)
- {
- var tmpsyle = {};
- tmpsyle.legendLabel = "raster";
- tmpsyle.filter = "";
- tmpsyle.index = 0;
- tmpsyle.staticIcon = true;
- var styleItem = new Fusion.Maps.MapServer.StyleItem(tmpsyle, tmpsyle.staticIcon);
- this.styles.push(styleItem);
- }
- else
- {
- var staticIcon = o.styles.length>=1 ? false : bRaster;
- for (var i=0; i<o.styles.length; i++) {
- var styleItem = new Fusion.Maps.MapServer.StyleItem(o.styles[i], staticIcon);
- this.styles.push(styleItem);
- }
- }
- },
- contains: function(fScale) {
- var testScale = Math.round(fScale);
- return testScale >= this.minScale && testScale <= this.maxScale;
- }
-});
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.StyleItem
- *
-* Implements the legend style items to get a legend icon from the server
-*/
-
-Fusion.Maps.MapServer.StyleItem = OpenLayers.Class({
- initialize: function(o, staticIcon) {
- this.legendLabel = o.legendLabel;
- this.filter = o.filter;
- this.index = o.index;
- this.staticIcon = staticIcon;
- },
- getLegendImageURL: function(fScale, layer) {
- var sl = Fusion.getScriptLanguage();
- var url = Fusion.getFusionURL() + '/' + layer.oMap.arch + '/' + sl + '/LegendIcon.' + sl;
- var sessionid = layer.oMap.getSessionID();
- var params = 'mapname='+layer.oMap._sMapname+"&session="+sessionid + '&layername='+layer.resourceId + '&classindex='+this.index;
- return url + '?'+params;
- }
-});
Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/lib/ApplicationDefinition.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -494,9 +494,42 @@
this.extension = {};
}
this.resourceId = this.extension.ResourceId ? this.extension.ResourceId[0] : '';
- if ( !Fusion.Maps[this.type] ) {
- Fusion.require(this.type + '/' + this.type + '.js');
+
+ var tagOptions = this.extension.Options;
+ this.layerOptions = {};
+ if (tagOptions && tagOptions[0]) {
+ for (var key in tagOptions[0]) {
+ this.layerOptions[key] = tagOptions[0][key][0];
+ if (this.layerOptions[key].toLowerCase() == 'true') {
+ this.layerOptions[key] = true;
+ } else if (this.layerOptions[key].toLowerCase() == 'false') {
+ this.layerOptions[key] = false;
+ }
+ if (key == 'maxExtent' || key == 'minExtent') {
+ this.layerOptions[key] = OpenLayers.Bounds.fromString(this.layerOptions[key])
+ }
+ }
}
+ var tagParams = this.extension.Parameters;
+ this.layerParams = {};
+ if (tagParams && tagParams[0]) {
+ for (var key in tagParams[0]) {
+ this.layerParams[key] = tagParams[0][key][0];
+ }
+ }
+
+ switch (this.type) {
+ case 'MapGuide':
+ case 'MapServer':
+ if ( !Fusion.Layers[this.type] ) {
+ //Fusion.require('layers/' + this.type + '/' + this.type + '.js');
+ Fusion.require(this.type + '/' + this.type + '.js');
+ }
+ break;
+ default:
+ Fusion.require('layers/Generic/Generic.js');
+ break;
+ }
}
});
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/lib/Map.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -50,14 +50,14 @@
Fusion.Constant.LAYER_DWF_TYPE = 5;
Fusion.Widget.Map = OpenLayers.Class(Fusion.Lib.EventMgr, {
- _oDomObj : null,
- _sDomObj : '',
- _sMapname : '',
- _nWidth : -1,
- _nHeight : -1,
- _fMetersperunit : -1,
- _fScale : -1,
- _nDpi : 96,
+ _oDomObj: null,
+ _sDomObj: '',
+ _sMapname: '',
+ _nWidth: -1,
+ _nHeight: -1,
+ _fMetersperunit: -1,
+ _fScale: -1,
+ _nDpi: 96,
_oCurrentExtents: null,
maxExtent: new OpenLayers.Bounds(),
_nWorkers: 0,
@@ -65,6 +65,7 @@
bSupressContextMenu: false,
aMaps: null,
+ mapsLoaded: false,
layerRoot: null,
singleTile: true,
fractionalZoom: true, //TODO: set this in AppDef?
@@ -76,12 +77,18 @@
initialize : function(widgetTag, mapGroup, widgetSet) {
this.widgetTag = widgetTag;
var name = widgetTag.name;
+ this.aMaps = [];
this.buttonSet = new Jx.ButtonSet();
this.widgetSet = widgetSet;
this._nCellSize = -1;
this._sDomObj = name;
this._oDomObj = $(this._sDomObj);
- this.layerRoot = new Fusion.Widget.Map.Group();
+ this.layerRoot = new Fusion.Layers.Group({
+ legendLabel: 'mapRoot',
+ uniqueId: 'mapRoot',
+ groupName: 'mapRoot',
+ visible: true
+ });
var jxl = this._oDomObj.retrieve('jxLayout');
if (jxl) {
@@ -147,19 +154,6 @@
this.handlers.push(this.wheelHandler);
}
- //create the 'Map' layer widgets defined in the MapGroup
- this.aMaps = [];
- this.mapGroup = mapGroup;
- for (var i=0; i<mapGroup.maps.length; ++i) {
- var mapTag = mapGroup.maps[i];
- if (Fusion.Maps[mapTag.type]) {
- this.aMaps[i] = eval("new Fusion.Maps."+mapTag.type+"(this,mapTag)");
- this.layerRoot.addGroup(this.aMaps[i].layerRoot);
-
- } else {
- //TODO: we can add more OpenLayers layers ...
- }
- }
$(name).widget = this;
this.registerEventID(Fusion.Event.MAP_EXTENTS_CHANGED);
@@ -185,6 +179,9 @@
this.aSelectionCallbacks = [];
this.bFetchingSelection = false;
+
+ //create the 'Map' layer widgets defined in the MapGroup
+ this.loadMapGroup(mapGroup);
},
mapLoaded: function() {
@@ -199,39 +196,55 @@
container.createWidgets(this.widgetSet, contextMenu);
this.setContextMenu(contextMenu);
}
-
}
-
},
loadMapGroup: function(mapGroup) {
- //clear any existing workers since loading a new map cancels all previous requests
- while (this.isBusy()) {
- this._removeWorker();
- }
-
//clear any existing selection
+ this.mapsLoaded = false;
this.clearSelection();
+ //this._addWorker();
this.mapGroup = mapGroup;
for (var i=0; i<this.aMaps.length; i++) {
+ if (this.aMaps[i].oLayerOL) {
this.aMaps[i].oLayerOL.destroy();
+ }
}
this.aMaps = [];
- this.layerRoot = new Fusion.Widget.Map.Group();
+ this.layerRoot.clear();
+
for (var i=0; i<mapGroup.maps.length; ++i) {
var mapTag = mapGroup.maps[i];
- if (Fusion.Maps[mapTag.type]) {
- this.aMaps[i] = eval("new Fusion.Maps."+mapTag.type+"(this,mapTag)");
+
+ if (Fusion.Layers[mapTag.type]) {
+ this.aMaps[i] = new Fusion.Layers[mapTag.type](this, mapTag, true);
this.layerRoot.addGroup(this.aMaps[i].layerRoot);
-
} else {
- //TODO: we can add more OpenLayers layers ...
+ this.aMaps[i] = new Fusion.Layers.Generic(this, mapTag, true);
+ this.layerRoot.addLayer(this.aMaps[i].layerRoot);
+ this.layerLoaded(); //Generic layers are loaded synchronously
}
+ this.aMaps[i].registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.layerLoaded,this));
}
},
+ layerLoaded: function() {
+ for (var i=0; i<this.aMaps.length; ++i) {
+ if (!this.aMaps[i].isMapLoaded()) {
+ return;
+ }
+ }
+ this.mapsLoaded = true;
+ if (this.aMaps.length == 1) {
+ this.oMapOL.setBaseLayer(this.aMaps[0].oLayerOL);
+ }
+ var initialExtent = this.setInitialExtents();
+ this.setExtents(initialExtent);
+ this.triggerEvent(Fusion.Event.MAP_LOADED);
+ },
+
/**
* Method: wheelChange
*
@@ -291,30 +304,30 @@
/**
* returns the dom element
*/
- getDomObj : function() {
+ getDomObj: function() {
return this._oDomObj;
},
- getMapName : function() {
+ getMapName: function() {
//TODO: what is the mapname in the case of multiple map layer objects?
//just return baselayer mapname for now
return this.aMaps[0].getMapName();
},
- getMapTitle : function() {
+ getMapTitle: function() {
//TODO: what is the map title in the case of multiple map layer objects?
//just return baselayer mapTitle for now
return this.aMaps[0]._sMapTitle;
},
- getSessionID : function() {
+ getSessionID: function() {
//TODO: what is the mapname in the case of multiple map layer objects?
//just return baselayer session ID for now
return this.aMaps[0].getSessionID();
},
- getDomId : function() {
+ getDomId: function() {
return this._sDomObj;
},
@@ -323,28 +336,31 @@
},
addMap: function(map) {
- if (!map.bSingleTile) {
- this.singleTile = false;
+
+ if (map.mapTag.layerOptions.maxExtent) {
+ this.projection = map.projection;
+ this.units = map.units;
+ this.maxExtent.extend(map.mapTag.layerOptions.maxExtent);
+ this.oMapOL.setOptions({
+ maxExtent: this.maxExtent,
+ units: map.units,
+ projection: this.projection});
}
- this.projection = map.projection;
- this.units = map.units;
- this.maxExtent.extend(map._oMaxExtent);
- this.oMapOL.setOptions({
- maxExtent: this.maxExtent,
- units: map.units,
- projection: this.projection});
-
+
//if bRestrictExtent is null, use the default OL behaviour with somewhat restricted map navigation
//if bRestrictExtent is set to true, map navigation is limited to the map extent
//if bRestrictExtent is set to false, map navigation is not restricted at all
if (this.bRestrictExtent != null) {
if (this.bRestrictExtent) {
- this.oMapOL.restrictedExtent = map._oMaxExtent;
+ this.oMapOL.restrictedExtent = map.mapTag.layerOptions.maxExtent;
} else {
this.oMapOL.restrictedExtent = false;
}
}
this.oMapOL.addLayer(map.oLayerOL);
+ console.log('layer added:'+map.oLayerOL.name);
+ map.registerForEvent(Fusion.Event.MAP_LOADED,
+ OpenLayers.Function.bind(this.mapLoadHandler, this));
map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
OpenLayers.Function.bind(this.selectionHandler, this));
map.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
@@ -383,6 +399,21 @@
},
/**
+ * Function: mapLoadHandler
+ *
+ * handle selection events from maps and republish for
+ * widgets as appropriate
+ */
+ mapLoadHandler: function() {
+ ++this.mapLoadCounter;
+ if (this.mapLoadCounter == this.aMaps.length) {
+ this._oInitialExtents = null;
+ this.fullExtents();
+ this.triggerEvent(Fusion.Event.MAP_LOADED);
+ }
+ },
+
+ /**
* Function: selectionHandler
*
* handle selection events from maps and republish for
@@ -504,7 +535,7 @@
* visual indicator is visible for the user. This is intended to be used
* internally by gMap but could be used by external tools if appropriate.
*/
- _addWorker : function() {
+ _addWorker: function() {
this._nWorkers += 1;
this.triggerEvent(Fusion.Event.MAP_BUSY_CHANGED, this);
this._oDomObj.style.cursor = 'wait';
@@ -517,7 +548,7 @@
* external tools if appropriate. Only call this function if
* addWorker was previously called
*/
- _removeWorker : function() {
+ _removeWorker: function() {
if (this._nWorkers > 0) {
this._nWorkers -= 1;
}
@@ -538,7 +569,10 @@
this.resize();
},
- resize : function() {
+ resize: function() {
+ if (!this.mapsLoaded) {
+ return;
+ }
//console.log('Fusion.Widget.Map.resize');
this.oMapOL.updateSize();
var d = $(this.getDomObj()).getContentBoxSize();
@@ -574,7 +608,9 @@
//update the timestamp param to prevent caching
for (var i=0; i<this.aMaps.length; i++ ) {
- this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
+ if (this.aMaps[i].oLayerOL.params) {
+ this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
+ }
}
this.oMapOL.zoomToExtent(oExtents,true);
this._oCurrentExtents = this.oMapOL.getExtent();
@@ -603,22 +639,9 @@
initialExtents = this.maxExtent;
}
} else {
- /*
- var viewSize = this.oMapOL.getSize();
- var oExtents = this.oMapOL.getMaxExtent();
- var center = oExtents.getCenterLonLat();
- var initRes = Math.max( oExtents.getWidth() / viewSize.w,
- oExtents.getHeight() / viewSize.h);
- var w_deg = viewSize.w * initRes/2;
- var h_deg = viewSize.h * initRes/2;
- initialExtents = new OpenLayers.Bounds(center.lon - w_deg,
- center.lat - h_deg,
- center.lon + w_deg,
- center.lat + h_deg);
- */
initialExtents = new OpenLayers.Bounds();
for (var i=0; i<this.aMaps.length; ++i) {
- initialExtents.extend(this.aMaps[i]._oMaxExtent);
+ initialExtents.extend(this.aMaps[i].getMaxExtent());
}
}
this.initialExtents = initialExtents;
@@ -798,7 +821,7 @@
*
* @return pixels
*/
- geoToPixMeasure : function(fGeo) {
+ geoToPixMeasure: function(fGeo) {
return parseInt(fGeo/this.oMapOL.getResolution());
},
@@ -811,7 +834,7 @@
* x - the x coordinate of the center
* y - the y coordinate of the center
*/
- getCurrentCenter : function() {
+ getCurrentCenter: function() {
var c = this.getCurrentExtents().getCenterLonLat();
return {x:c.lon, y:c.lat};
},
@@ -820,7 +843,7 @@
*
* returns the current extents
*/
- getCurrentExtents : function() {
+ getCurrentExtents: function() {
return this.oMapOL.getExtent();
},
@@ -846,15 +869,15 @@
fY + h_deg / 2);
},
- getScale : function() {
+ getScale: function() {
return this.oMapOL.getScale();
},
- getResolution : function() {
+ getResolution: function() {
return this.oMapOL.getResolution();
},
- getUnits : function() {
+ getUnits: function() {
return this.oMapOL.baseLayer.units;
},
@@ -862,11 +885,11 @@
return this.oMapOL.getSize();
},
- getEventPosition : function(e) {
+ getEventPosition: function(e) {
return this.oMapOL.events.getMousePosition(e);
},
- setCursor : function(cursor) {
+ setCursor: function(cursor) {
this.cursor = cursor;
if (this.isBusy()) {
return;
@@ -892,7 +915,7 @@
* @param fnCB function Call back function name
*
*/
- observeEvent : function(sEventName, fnCB)
+ observeEvent: function(sEventName, fnCB)
{
OpenLayers.Event.observe(this._oDomObj, sEventName, fnCB, false);
},
@@ -905,7 +928,7 @@
* @param fnCB function Call back function name
*
*/
- stopObserveEvent : function(sEventName, fnCB)
+ stopObserveEvent: function(sEventName, fnCB)
{
OpenLayers.Event.stopObserving(this._oDomObj, sEventName, fnCB, false);
},
@@ -918,7 +941,7 @@
*
* @param nId integer widget id
*/
- activateWidget : function(oWidget)
+ activateWidget: function(oWidget)
{
/*console.log('Fusion.Widget.Map.activateWidget ' + oWidget.getName());*/
// if (oWidget.isMutEx()) {
@@ -940,7 +963,7 @@
*
* @param oWidget the widget to deactivate
*/
- deactivateWidget : function(oWidget)
+ deactivateWidget: function(oWidget)
{
/*console.log('Fusion.Widget.Map.deactivateWidget ' + oWidget.getName());*/
//oWidget.deactivate();
@@ -977,106 +1000,7 @@
}
});
- /****************************************************************************
- * Class: Fusion.Widget.Map.Layer
- *
- * generic class for map layers. This class is primarily for legends.
- * **********************************************************************/
-Fusion.Event.LAYER_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Widget.Map.Layer = OpenLayers.Class(Fusion.Lib.EventMgr, {
- name: null,
- initialize: function(name) {
- this.name = name;
- this.registerEventID(Fusion.Event.LAYER_PROPERTY_CHANGED);
- },
- clear: function() {},
- set: function(property, value) {
- this[property] = value;
- this.triggerEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, this);
- }
-});
- /****************************************************************************
- * Class: Fusion.Widget.Map.Group
- *
- * generic class for map layer groups. This class is primarily for legends.
- * **********************************************************************/
-Fusion.Event.GROUP_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Widget.Map.Group = OpenLayers.Class(Fusion.Lib.EventMgr, {
- name: null,
- groups: null,
- layers: null,
- initialize: function(name) {
- this.name = name;
- this.groups = [];
- this.layers = [];
- this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
- },
- clear: function() {
- for (var i=0; i<this.groups.length; i++) {
- this.groups[i].clear();
- }
- for (var i=0; i<this.layers.length; i++) {
- this.layers[i].clear();
- }
- this.groups = [];
- this.layers = [];
- },
- set: function(property, value) {
- this[property] = value;
- this.triggerEvent(Fusion.Event.GROUP_PROPERTY_CHANGED, this);
- },
- addGroup: function(group,reverse) {
- group.parentGroup = this;
- if (reverse) {
- this.groups.unshift(group);
- } else {
- this.groups.push(group);
- }
- },
- addLayer: function(layer,reverse) {
- layer.parentGroup = this;
- if (reverse) {
- this.layers.unshift(layer);
- } else {
- this.layers.push(layer);
- }
- },
- findGroup: function(name) {
- return this.findGroupByAttribute('name', name);
- },
- findGroupByAttribute: function(attribute, value) {
- if (this[attribute] == value) {
- return this;
- }
- for (var i=0; i<this.groups.length; i++) {
- var group = this.groups[i].findGroupByAttribute(attribute, value);
- if (group) {
- return group;
- }
- }
- return null;
- },
- findLayer: function(name) {
- return this.findLayerByAttribute('name', name);
- },
- findLayerByAttribute: function(attribute, value) {
- for (var i=0; i<this.layers.length; i++) {
- if (this.layers[i][attribute] == value) {
- return this.layers[i];
- }
- }
- for (var i=0; i<this.groups.length; i++) {
- var layer = this.groups[i].findLayerByAttribute(attribute,value);
- if (layer) {
- return layer;
- }
- }
- return null;
- }
-});
-
-
/**
* SelectionObject
*
Modified: trunk/templates/mapserver/standard/ApplicationDefinition.xml
===================================================================
--- trunk/templates/mapserver/standard/ApplicationDefinition.xml 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/templates/mapserver/standard/ApplicationDefinition.xml 2008-11-12 21:10:10 UTC (rev 1662)
@@ -27,6 +27,72 @@
</Extension>
</Map>
</MapGroup>
+ <MapGroup id="mixed" xsi:type="MapType">
+ <Map xsi:type="WMSLayerType">
+ <Type>WMS</Type>
+ <Extension>
+ <ResourceId>http://localhost/cgi-bin/testwms.exe</ResourceId>
+ <Options>
+ <name>test WMS</name>
+ <isBaseLayer>true</isBaseLayer>
+ <singleTile>true</singleTile>
+ <!--maxResolution>auto</maxResolution>
+ <minScale>1000000000</minScale-->
+ </Options>
+ <Parameters>
+ <layers>bathymetry</layers>
+ <transparent>true</transparent>
+ </Parameters>
+ </Extension>
+ </Map>
+ <Map xsi:type="MapLayerType">
+ <Type>MapServer</Type>
+ <SingleTile>true</SingleTile>
+ <Extension>
+ <MapFile>/ms4w/apps/gmap/htdocs/gmapLonLat.map</MapFile>
+ <Options>
+ <isBaseLayer>false</isBaseLayer>
+ <singleTile>true</singleTile>
+ </Options>
+ </Extension>
+ </Map>
+ </MapGroup>
+ <MapGroup id="wmsOnly" xsi:type="MapType">
+ <Map xsi:type="WMSLayerType">
+ <Type>WMS</Type>
+ <Extension>
+ <ResourceId>http://localhost/cgi-bin/testwms.exe</ResourceId>
+ <Options>
+ <name>test WMS</name>
+ <singleTile>true</singleTile>
+ <isBaseLayer>true</isBaseLayer>
+ <transitionEffect>resize</transitionEffect>
+ <maxExtent>-141,41,-43,90</maxExtent>
+ <maxResolution>auto</maxResolution>
+ <!--minScale>1000000000</minScale-->
+ </Options>
+ <Parameters>
+ <layers>bathymetry</layers>
+ <transparent>true</transparent>
+ </Parameters>
+ </Extension>
+ </Map>
+ </MapGroup>
+ <MapGroup id="google" xsi:type="MapType">
+ <Map xsi:type="WMSLayerType">
+ <Type>Google</Type>
+ <Extension>
+ <ResourceId>google</ResourceId>
+ <Options>
+ <name>GoogleLayer</name>
+ <type>G_PHYSICAL_MAP</type>
+ <isBaseLayer>true</isBaseLayer>
+ <sphericalMercator>true</sphericalMercator>
+ <maxExtent>-141,41,-43,90</maxExtent>
+ </Options>
+ </Extension>
+ </Map>
+ </MapGroup>
<MapGroup id="mapserverKeymap" xsi:type="MapType">
<Map xsi:type="MapLayerType">
<Type>MapServer</Type>
@@ -1060,14 +1126,15 @@
<MapId>reliance-roads</MapId>
</MapWidget>
-<!-- OVERVIEW MAP -->
+<!-- OVERVIEW MAP -->
+
<Widget xsi:type="WidgetType">
<Name>OverviewMap</Name>
<Type>OverviewMap</Type>
<Description/>
<Extension xsi:type="CustomContentType">
- <!--MapId>sheboyganOverview</MapId-->
+ <!--MapId>mapserverKeymap</MapId-->
</Extension>
</Widget>
Modified: trunk/templates/mapserver/standard/index.html
===================================================================
--- trunk/templates/mapserver/standard/index.html 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/templates/mapserver/standard/index.html 2008-11-12 21:10:10 UTC (rev 1662)
@@ -3,9 +3,11 @@
<html>
<head>
<title>Sample Fusion Application</title>
-<!-- change the source of the following tag to point to your fusion installation -->
+<!-- change the source of the following tag to point to your fusion installation
+ <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
+ -->
<script type="text/javascript" src="../../../lib/fusion.js"></script>
-<link rel="stylesheet" href="themes/delicious/jxtheme.css" type="text/css" media="screen" charset="utf-8">
+<link rel="stylesheet" href="themes/delicious/jxtheme.uncompressed.css" type="text/css" media="screen" charset="utf-8">
<link rel="stylesheet" href="icons.css" type="text/css" media="screen" charset="utf-8">
<style type="text/css">
#Statusbar .spanCursorPosition,
@@ -100,14 +102,13 @@
<div id="TaskPane"></div>
<div id="PoweredBy" class="statusBarItem">
<a href="http://mapserver.gis.umn.edu.org/" target="_blank">
- <img src="images/PoweredBy_MapServer.gif" width="137" height="18" border="0">
+ <img src="images/PoweredBy_en.gif" width="137" height="18" border="0">
</a>
</div>
</div>
<div id="BusyIndicator" style="visibility: hidden;">
- <img src="images/icon_loading.gif" width="30" height="14">
</div>
</body>
Modified: trunk/templates/mapserver/standard/themes/delicious/jxtheme.uncompressed.css
===================================================================
--- trunk/templates/mapserver/standard/themes/delicious/jxtheme.uncompressed.css 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/templates/mapserver/standard/themes/delicious/jxtheme.uncompressed.css 2008-11-12 21:10:10 UTC (rev 1662)
@@ -2267,3 +2267,19 @@
vertical-align: middle;
}
+.olControlOverviewMapExtentRectangle {
+ overflow: hidden;
+ background-image: url("img/blank.gif");
+ cursor: move;
+ border: 2px dotted red;
+}
+
+.olHandlerBoxZoomBox {
+ border: 2px solid red;
+ position: absolute;
+ background-color: white;
+ opacity: 0.50;
+ font-size: 1px;
+ filter: alpha(opacity=50);
+}
+
Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/widgets/Legend.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -535,7 +535,7 @@
layer.parentGroup.legend.treeItem.append(layer.legend.treeItem);
} else {
if (range.styles.length > 0) {
- layer.legend.treeItem.domImg.style.backgroundImage = 'url('+range.styles[0].getLegendImageURL(fScale, layer, this.getMap())+')' ;
+ layer.legend.treeItem.domImg.style.backgroundImage = 'url('+layer.oMap.getLegendImageURL(fScale, layer, range.styles[0])+')' ;
$(layer.legend.treeItem.domObj).removeClass('jxDisabled');
} else {
$(layer.legend.treeItem.domObj).addClass('jxDisabled');
@@ -618,7 +618,7 @@
opt.image = this.imgDisabledLayerIcon;
opt.enabled = false;
} else {
- opt.image = style.getLegendImageURL(scale, layer);
+ opt.image = layer.oMap.getLegendImageURL(scale, layer, style);
}
var item = new Jx.TreeItem(opt);
Modified: trunk/widgets/Navigator.js
===================================================================
--- trunk/widgets/Navigator.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/widgets/Navigator.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -185,14 +185,14 @@
map.deactivateWidget(map.oActiveWidget);
}
if (!this.bInternalChange) {
- var map = this.getMap().oMapOL;
- var baseLayer = map.baseLayer;
+ var olMap = this.getMap().oMapOL;
+ var baseLayer = olMap.baseLayer;
if (baseLayer.singleTile) {
var scale = Math.pow(9,value/9);
var resolution = OpenLayers.Util.getResolutionFromScale(scale, baseLayer.units);
resolution += baseLayer.minResolution;
this.bInternalChange = true;
- map.zoomTo(map.getZoomForResolution(resolution));
+ olMap.zoomTo(olMap.getZoomForResolution(resolution));
this.bInternalChange = false;
} else {
var res = olMap.baseLayer.resolutions;
Modified: trunk/widgets/OverviewMap.js
===================================================================
--- trunk/widgets/OverviewMap.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/widgets/OverviewMap.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -32,9 +32,9 @@
Fusion.Widget.OverviewMap = OpenLayers.Class(Fusion.Widget, {
oSize: null,
- nMinRatio : 4,
- nMaxRatio : 32,
- bDisplayed : false,
+ nMinRatio: 4,
+ nMaxRatio: 32,
+ bDisplayed: false,
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
@@ -54,8 +54,12 @@
var mainMap = this.getMap();
mapTag = mainMap.mapGroup.maps[0]; //TODO: always use the baselayer Map in the group?
}
- this.mapObject = eval("new Fusion.Maps."+mapTag.type+"(this.getMap(),mapTag,false)");
- this.mapObject.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.loadOverview, this));
+ if (Fusion.Layers[mapTag.type]) {
+ this.mapObject = new Fusion.Layers[mapTag.type](this.getMap(), mapTag, false);
+ } else {
+ this.mapObject = new Fusion.Layers.Generic(this, mapTag, false);
+ }
+ this.mapObject.registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.loadOverview, this));
//first set the size to the size of the DOM element if available
if (this.domObj) {
Modified: trunk/widgets/SelectionInfo.js
===================================================================
--- trunk/widgets/SelectionInfo.js 2008-11-12 20:49:29 UTC (rev 1661)
+++ trunk/widgets/SelectionInfo.js 2008-11-12 21:10:10 UTC (rev 1662)
@@ -79,11 +79,17 @@
update: function() {
var olMap = this.getMap();
var aMaps = olMap.getAllMaps();
- var map = aMaps[0];
- if (map.hasSelection()) {
- var layers = map.getSelectedLayers();
- var nLayers = layers.length;
- var nFeatures = map.getSelectedFeatureCount();
+ var nLayers = 0;
+ var nFeatures = 0;
+ for (var i=0; i<aMaps.length; ++i) {
+ var map = aMaps[i];
+ if (map.hasSelection()) {
+ var layers = map.getSelectedLayers();
+ nLayers += layers.length;
+ nFeatures += map.getSelectedFeatureCount();
+ }
+ }
+ if (nFeatures > 0) {
if (this.template) {
this.domSpan.innerHTML = this.template.replace('{0}',nFeatures).replace('{1}',nLayers);
} else {
More information about the fusion-commits
mailing list