[fusion-commits] r1730 - in branches/fusion-1.1: MapGuide lib
widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Jan 7 14:46:05 EST 2009
Author: madair
Date: 2009-01-07 14:46:05 -0500 (Wed, 07 Jan 2009)
New Revision: 1730
Modified:
branches/fusion-1.1/MapGuide/MapGuide.js
branches/fusion-1.1/lib/Map.js
branches/fusion-1.1/lib/fusion.js
branches/fusion-1.1/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
Modified: branches/fusion-1.1/MapGuide/MapGuide.js
===================================================================
--- branches/fusion-1.1/MapGuide/MapGuide.js 2008-12-19 20:48:21 UTC (rev 1729)
+++ branches/fusion-1.1/MapGuide/MapGuide.js 2009-01-07 19:46:05 UTC (rev 1730)
@@ -139,7 +139,7 @@
}
},
- createSessionCB : function(xhr) {
+ createSessionCB: function(xhr) {
if (xhr.status == 200) {
var o;
eval('o='+xhr.responseText);
@@ -540,7 +540,7 @@
*
* Returns the MapGuide layer object as identified by the layer name
*/
- getLayerByName : function(name)
+ getLayerByName: function(name)
{
var oLayer = null;
for (var i=0; i<this.aLayers.length; i++)
@@ -565,7 +565,7 @@
hasSelection: function() { return this.bSelectionOn; },
- getSelectionCB : function(userFunc, layers, startend, r) {
+ getSelectionCB: function(userFunc, layers, startend, r) {
if (r.status == 200)
{
var o;
@@ -592,7 +592,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;
@@ -603,7 +603,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) {
@@ -616,7 +616,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) {
@@ -677,7 +677,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) {
/*for now always go back to server to fetch selection */
@@ -703,7 +703,7 @@
/**
Call back function when selection is cleared
*/
- selectionCleared : function()
+ selectionCleared: function()
{
//clear the selection count for the layers
for (var j=0; j<this.aLayers.length; ++j) {
@@ -722,7 +722,7 @@
/**
Utility function to clear current selection
*/
- clearSelection : function() {
+ clearSelection: function() {
if (this.hasSelection()) {
var s = this.arch + '/' + Fusion.getScriptLanguage() + "/ClearSelection." + Fusion.getScriptLanguage() ;
var options = {
@@ -737,7 +737,7 @@
/**
removes the queryLayer from the map
*/
- removeQueryLayer : function() {
+ removeQueryLayer: function() {
if (this.queryLayer) {
this.queryLayer.destroy();
this.queryLayer = null;
@@ -748,7 +748,7 @@
/**
Call back function when slect functions are called (eg queryRect)
*/
- processQueryResults : function(zoomTo, r) {
+ processQueryResults: function(zoomTo, r) {
this.mapWidget._removeWorker();
if (r.responseText) { //TODO: make the equivalent change to MapServer.js
var oNode;
@@ -792,7 +792,7 @@
/**
Do a query on the map
*/
- query : function(options) {
+ query: function(options) {
this.mapWidget._addWorker();
//clear the selection count for the layers
@@ -917,6 +917,7 @@
}
}
},
+
hideGroup: function( group, noDraw ) {
this.processGroupEvents(group, false);
if (group.groupName == 'layerRoot') {
@@ -928,11 +929,13 @@
}
}
},
+
refreshLayer: function( layer ) {
this.aRefreshLayers.push(layer.uniqueId);
this.drawMap();
},
- setParameter : function(param, value) {
+
+ setParameter: function(param, value) {
if (param == 'SelectionType') {
this.selectionType = value;
}
@@ -1027,6 +1030,7 @@
params.parameters = {'session': this.getSessionID()};
Fusion.ajaxRequest(s, params);
},
+
getGroupInfoUrl: function(groupName) {
if (this.mapInfo) {
var groups = this.mapInfo.links.groups;
@@ -1038,6 +1042,7 @@
}
return null;
},
+
getLayerInfoUrl: function(layerName) {
if (this.mapInfo) {
var layers = this.mapInfo.links.layers;
@@ -1048,6 +1053,24 @@
}
}
return null;
+ },
+
+ getLinkParams: function() {
+ var queryParams = {};
+ queryParams.theme = this.sMapResourceId;
+ if (this.aShowLayers.length > 0) {
+ queryParams.showlayers = this.aShowLayers.toString();
+ }
+ if (this.aHideLayers.length > 0) {
+ queryParams.hidelayers = this.aHideLayers.toString();
+ }
+ if (this.aShowGroups.length > 0) {
+ queryParams.showgroups = this.aShowGroups.toString();
+ }
+ if (this.aHideGroups.length > 0) {
+ queryParams.hidegroups = this.aHideGroups.toString();
+ }
+ return queryParams;
}
});
Modified: branches/fusion-1.1/lib/Map.js
===================================================================
--- branches/fusion-1.1/lib/Map.js 2008-12-19 20:48:21 UTC (rev 1729)
+++ branches/fusion-1.1/lib/Map.js 2009-01-07 19:46:05 UTC (rev 1730)
@@ -356,6 +356,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)) {
}
@@ -397,6 +398,7 @@
*/
clearSelection: function() {
this.oSelection = null;
+ this.lastQueryOptions = null;
for (var i=0; i<this.aMaps.length; i++ ) {
this.aMaps[i].clearSelection();
}
@@ -930,6 +932,49 @@
return (this.oMapOL.getExtent() != null);
},
+ getLinkParams: function() {
+ var queryParams = {
+ extent: this.getCurrentExtents().toBBOX()
+ };
+ /*
+ if (this.oSelection) {
+ var layers = '';
+ for (var mapKey in this.oSelection) {
+ var join = '';
+ for (var i=0; i<this.oSelection[mapKey].aLayers.length; ++i) {
+ layers += this.oSelection[mapKey].aLayers[i].sName + join;
+ join = ',';
+ }
+ }
+ queryParams.selectlayer = layers;
+ }
+ */
+ 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: branches/fusion-1.1/lib/fusion.js
===================================================================
--- branches/fusion-1.1/lib/fusion.js 2008-12-19 20:48:21 UTC (rev 1729)
+++ branches/fusion-1.1/lib/fusion.js 2009-01-07 19:46:05 UTC (rev 1730)
@@ -987,7 +987,7 @@
this.parseQueryString();
}
p = p.toLowerCase();
- if (this.queryParams[p]) {
+ if (this.queryParams[p] && typeof this.queryParams[p] != 'function') {
return this.queryParams[p];
} else {
return '';
Modified: branches/fusion-1.1/widgets/LinkToView.js
===================================================================
--- branches/fusion-1.1/widgets/LinkToView.js 2008-12-19 20:48:21 UTC (rev 1729)
+++ branches/fusion-1.1/widgets/LinkToView.js 2009-01-07 19:46:05 UTC (rev 1730)
@@ -31,7 +31,7 @@
Fusion.Widget.LinkToView = OpenLayers.Class(Fusion.Widget, {
- initialize : function(widgetTag) {
+ initialize: function(widgetTag) {
//console.log('LinkToView.initialize');
Fusion.Widget.prototype.initialize.apply(this, [widgetTag, false]);
@@ -46,7 +46,12 @@
if (typeof queryParams[param] == 'function') {
continue;
}
- if (param == 'extent') {
+ if (param == 'extent' ||
+ param == 'filter' ||
+ param == 'spatialfilter' ||
+ param == 'variant' ||
+ param == 'theme' ||
+ param == 'selectlayer') {
continue;
}
this.baseUrl += join + param + '=' + queryParams[param];
@@ -63,13 +68,20 @@
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();
+ 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