[fusion-commits] r1733 - in trunk: layers layers/MapGuide lib
widgets widgets/LinkToView
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Jan 8 13:35:06 EST 2009
Author: madair
Date: 2009-01-08 13:35:06 -0500 (Thu, 08 Jan 2009)
New Revision: 1733
Added:
trunk/widgets/LinkToView/
trunk/widgets/LinkToView/LinkToView.css
Modified:
trunk/layers/Layers.js
trunk/layers/MapGuide/MapGuide.js
trunk/lib/Map.js
trunk/lib/fusion.js
trunk/widgets/LinkToView.js
Log:
re #34: added getMapLink functions to Map and Mapguide to return permalink parameters; small bug in Fusion.getQueryParams when param name is a function - applied to trunk
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2009-01-08 18:34:28 UTC (rev 1732)
+++ trunk/layers/Layers.js 2009-01-08 18:35:06 UTC (rev 1733)
@@ -314,6 +314,7 @@
this.displayInLegend = o.displayInLegend;
this.expandInLegend = o.expandInLegend;
this.visible = o.visible;
+ this.initiallyVisible = o.visible;
this.actuallyVisible = o.actuallyVisible;
this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
},
@@ -443,6 +444,7 @@
this.statusDefault = o.statusdefault;
this.editable = o.editable;
this.visible = o.visible;
+ this.initiallyVisible = o.visible;
this.selectable = o.selectable;
Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js 2009-01-08 18:34:28 UTC (rev 1732)
+++ trunk/layers/MapGuide/MapGuide.js 2009-01-08 18:35:06 UTC (rev 1733)
@@ -133,11 +133,25 @@
mapSessionCreated: function() {
if (this.sMapResourceId != '') {
- this.loadMap(this.sMapResourceId);
+ var options = {};
+ if (this.bIsMapWidgetLayer) {
+ var showlayers = Fusion.getQueryParam('showlayers');
+ var hidelayers = Fusion.getQueryParam('hidelayers');
+ var showgroups = Fusion.getQueryParam('showgroups');
+ var hidegroups = Fusion.getQueryParam('hidegroups');
+ var options = {
+ showlayers: showlayers == '' ? [] : showlayers.split(','),
+ hidelayers: hidelayers == '' ? [] : hidelayers.split(','),
+ showgroups: showgroups == '' ? [] : showgroups.split(','),
+ hidegroups: hidegroups == '' ? [] : hidegroups.split(',')
+ };
+ }
+ this.loadMap(this.sMapResourceId, options);
}
window.setInterval(OpenLayers.Function.bind(this.pingServer, this), this.keepAliveInterval * 1000);
},
+
sessionReady: function() {
return (typeof this.session[0] == 'string');
},
@@ -978,6 +992,43 @@
Fusion.ajaxRequest(s, 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;
+ },
+
getLegendImageURL: function(fScale, layer, style) {
var url = Fusion.getConfigurationItem('mapguide', 'mapAgentUrl');
url += "?OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID();
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2009-01-08 18:34:28 UTC (rev 1732)
+++ trunk/lib/Map.js 2009-01-08 18:35:06 UTC (rev 1733)
@@ -393,6 +393,7 @@
* dispatch query requests to maps
*/
query: function(options) {
+ this.lastQueryOptions = options;
for (var i=0; i<this.aMaps.length; i++ ) {
if (this.aMaps[i].query(options)) {
}
@@ -449,6 +450,7 @@
*/
clearSelection: function() {
this.oSelection = null;
+ this.lastQueryOptions = null;
for (var i=0; i<this.aMaps.length; i++ ) {
this.aMaps[i].clearSelection();
}
@@ -977,6 +979,36 @@
return (this.oMapOL.getExtent() != null);
},
+ getLinkParams: function() {
+ var queryParams = {
+ extent: this.getCurrentExtents().toBBOX()
+ };
+ if (this.lastQueryOptions) {
+ if (this.lastQueryOptions.filter) {
+ queryParams.filter = this.lastQueryOptions.filter;
+ }
+ if (this.lastQueryOptions.geometry) {
+ queryParams.spatialfilter = this.lastQueryOptions.geometry;
+ }
+ if (this.lastQueryOptions.queryHiddenLayers) {
+ queryParams.queryHiddenLayers = this.lastQueryOptions.queryHiddenLayers;
+ }
+ if (this.lastQueryOptions.maxFeatures) {
+ queryParams.maxfeatures = this.lastQueryOptions.maxFeatures;
+ }
+ if (this.lastQueryOptions.layers) {
+ queryParams.selectlayer = this.lastQueryOptions.layers;
+ }
+ if (this.lastQueryOptions.selectionType) {
+ queryParams.variant = this.lastQueryOptions.selectionType;
+ }
+ }
+ for (var i=0; i< this.aMaps.length; ++i) {
+ queryParams = OpenLayers.Util.extend(queryParams, this.aMaps[i].getLinkParams());
+ }
+ return OpenLayers.Util.getParameterString(queryParams);
+ },
+
supressContextMenu: function( bSupress ) {
this.bSupressContextMenu = bSupress;
},
Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js 2009-01-08 18:34:28 UTC (rev 1732)
+++ trunk/lib/fusion.js 2009-01-08 18:35:06 UTC (rev 1733)
@@ -1010,7 +1010,7 @@
this.parseQueryString();
}
p = p.toLowerCase();
- if (this.queryParams[p]) {
+ if (this.queryParams[p] && typeof this.queryParams[p] == 'string') {
return this.queryParams[p];
} else {
return '';
Added: trunk/widgets/LinkToView/LinkToView.css
===================================================================
--- trunk/widgets/LinkToView/LinkToView.css (rev 0)
+++ trunk/widgets/LinkToView/LinkToView.css 2009-01-08 18:35:06 UTC (rev 1733)
@@ -0,0 +1,7 @@
+a.anchorLinkToView {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11px;
+ line-height: 14px;
+ padding: 4px;
+}
+
Modified: trunk/widgets/LinkToView.js
===================================================================
--- trunk/widgets/LinkToView.js 2009-01-08 18:34:28 UTC (rev 1732)
+++ trunk/widgets/LinkToView.js 2009-01-08 18:35:06 UTC (rev 1733)
@@ -31,41 +31,63 @@
Fusion.Widget.LinkToView = OpenLayers.Class(Fusion.Widget, {
+
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
this.baseUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?';
//remove any existing extent param
- var queryParams = Fusion.parseQueryString();
var join = '';
- for (var param in queryParams) {
- if (typeof queryParams[param] == 'function') {
- continue;
+ for (var param in Fusion.queryParams) {
+ if (typeof Fusion.queryParams[param] == 'string') {
+ if (param == 'extent' ||
+ param == 'filter' ||
+ param == 'spatialfilter' ||
+ param == 'variant' ||
+ param == 'theme' ||
+ param == 'selectlayer' ||
+ param == 'showlayers' ||
+ param == 'hidelayers' ||
+ param == 'showgroups' ||
+ param == 'hidegroups' ) {
+ continue;
+ }
+ this.baseUrl += join + param + '=' + Fusion.queryParams[param];
+ join = '&';
}
- if (param == 'extent') {
- continue;
- }
- this.baseUrl += join + param + '=' + queryParams[param];
- join = '&';
}
+ this.anchorLabel = json.Label ? json.Label[0] : (this.domObj ? this.domObj.innerHTML : 'Link to View');
- this.anchorLabel = json.Label ? json.Label[0] : (this.domObj.innerHTML ? this.domObj.innerHTML : 'Link to View');
-
+ Fusion.addWidgetStyleSheet(widgetTag.location + 'LinkToView/LinkToView.css');
this.anchor = document.createElement('a');
this.anchor.className = 'anchorLinkToView';
this.anchor.href = this.baseUrl;
this.anchor.innerHTML = this.anchorLabel;
this.anchor.title = json.Tooltip ? json.Tooltip[0] : 'Right-click to copy or bookmark link to current view';
- this.domObj.innerHTML = '';
- this.domObj.appendChild(this.anchor);
-
- this.getMap().registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, OpenLayers.Function.bind(this.updateLink, this));
+
+ this.getMap().oMapOL.events.register("addlayer", this, this.setListener);
this.enable();
},
- updateLink : function() {
- var sBbox = this.getMap().getCurrentExtents().toBBOX();
+ setUiObject: function(uiObj) {
+ Fusion.Widget.prototype.setUiObject.apply(this, [uiObj]);
+ if (this.uiObj.domObj) {
+ this.uiObj.domObj.appendChild(this.anchor);
+ } else {
+ this.uiObj.appendChild(this.anchor);
+ }
+ },
+
+ setListener: function(evt) {
+ var layer = evt.layer;
+ //register on the OL loadend event to update the link because this event
+ //is fired whenever the layers are redrawn
+ layer.events.register("loadend", this, this.updateLink);
+ },
+
+ updateLink: function() {
var join = (this.baseUrl.indexOf('?')==this.baseUrl.length-1)?'':'&';
- this.anchor.href = this.baseUrl + join +'extent=' + sBbox;
+ var queryStr = this.getMap().getLinkParams();
+ this.anchor.href = this.baseUrl + join + queryStr;
}
});
More information about the fusion-commits
mailing list