[fusion-commits] r2863 - trunk/layers/MapGuide
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Jul 9 20:27:07 PDT 2014
Author: jng
Date: 2014-07-09 20:27:07 -0700 (Wed, 09 Jul 2014)
New Revision: 2863
Modified:
trunk/layers/MapGuide/MapGuide.js
Log:
#620: Fix extending selections via shift-click not working when native service support (ie. MapGuide Server is 2.6 or above) is enabled.
Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js 2014-07-10 02:24:21 UTC (rev 2862)
+++ trunk/layers/MapGuide/MapGuide.js 2014-07-10 03:27:07 UTC (rev 2863)
@@ -1223,20 +1223,41 @@
Fusion.ajaxRequest(getPropertiesScript, options);
},
- updateMapSelection: function (selText, zoomTo) {
- this.mapWidget._addWorker();
- var sl = Fusion.getScriptLanguage();
- var updateSelectionScript = 'layers/' + this.arch + '/' + sl + '/SaveSelection.' + sl;
- var params = {
- 'mapname': this.getMapName(),
- 'session': this.getSessionID(),
- 'selection': selText,
- 'seq': Math.random(),
- 'getextents' : zoomTo ? 'true' : 'false'
- };
- var options = {onSuccess: OpenLayers.Function.bind(this.renderSelection, this, zoomTo),
- parameters:params};
- Fusion.ajaxRequest(updateSelectionScript, options);
+ updateMapSelection: function (selText, zoomTo, mergeSelection) {
+ this.mapWidget._addWorker();
+ if (this.bUseNativeServices) {
+ //NOTE:
+ // This code path assumes our "2.6" or above MapGuide Server is assumed to have this particular
+ // issue fixed: http://trac.osgeo.org/mapguide/changeset/8288
+ // This will be true for MapGuide Open Source 2.6 Final. This may not be true for AIMS 2015.
+ var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures2(this.getSessionID(),
+ this._sMapname,
+ null, //geometry
+ -1, //max features
+ 1, //persist
+ this.selectionType,
+ selText,
+ null,
+ 0, //All layers
+ 4, //hyperlinks only
+ this.selectionColor,
+ this.selectionImageFormat);
+ var callback = OpenLayers.Function.bind(this.onNativeSelectionUpdate, this, zoomTo);
+ Fusion.oBroker.dispatchRequest(r, callback);
+ } else {
+ var sl = Fusion.getScriptLanguage();
+ var updateSelectionScript = 'layers/' + this.arch + '/' + sl + '/SaveSelection.' + sl;
+ var params = {
+ 'mapname': this.getMapName(),
+ 'session': this.getSessionID(),
+ 'selection': selText,
+ 'seq': Math.random(),
+ 'getextents' : zoomTo ? 'true' : 'false'
+ };
+ var options = {onSuccess: OpenLayers.Function.bind(this.renderSelection, this, zoomTo),
+ parameters:params};
+ Fusion.ajaxRequest(updateSelectionScript, options);
+ }
},
@@ -1362,6 +1383,32 @@
}
},
+ onNativeSelectionUpdate: function(zoomTo, r) {
+ //Set up the expected response text for renderSelection()
+ var sel = this.previousSelection;
+ var resp = {
+ hasSelection: false,
+ layers: [],
+ extents: null
+ };
+ for (var i = 0; i < sel.getNumLayers(); i++) {
+ var layer = sel.getLayer(i);
+ var nFeatures = layer.getNumFeatures();
+ if (nFeatures > 0) {
+ resp.hasSelection = true;
+ var layerId = layer.getName();
+ var oLayer = this.getLayerById(layerId);
+ resp.layers.push(oLayer.layerName);
+ resp[oLayer.layerName] = {
+ featureCount: nFeatures
+ };
+ }
+ }
+ r.responseText = JSON.stringify(resp);
+ this.renderSelection(zoomTo, r);
+ this.processSelectedFeaturePropertiesNode(this.previousAttributes);
+ },
+
/**
Call back function when select functions are called (eg queryRect)
to render the selection
@@ -1885,26 +1932,70 @@
//this.processSelectedFeatureInfo(r, false);
},
+ mergeAttributes: function(attributes, prevAttributes) {
+ //Start off with prevAttributes as the base
+ var merged = {};
+ merged.hasSelection = prevAttributes.hasSelection;
+ merged.extents = prevAttributes.extents;
+ merged.layers = prevAttributes.layers;
+ for (var i = 0; i < merged.layers.length; i++) {
+ var layerName = merged.layers[i][0];
+ merged[layerName] = prevAttributes[layerName];
+ }
+ //Expand extents
+ if (!merged.extents && attributes.extents) {
+ merged.extents = attributes.extents;
+ } else {
+ if (attributes.extents) {
+ if (attributes.extents.minx < merged.extents.minx)
+ merged.extents.minx = attributes.extents.minx;
+ if (attributes.extents.miny < merged.extents.miny)
+ merged.extents.miny = attributes.extents.miny;
+ if (attributes.extents.maxx > merged.extents.maxx)
+ merged.extents.maxx = attributes.extents.maxx;
+ if (attributes.extents.maxy > merged.extents.maxy)
+ merged.extents.maxy = attributes.extents.maxy;
+ }
+ }
+ //Bring in attributes
+ for (var i = 0; i < attributes.layers.length; i++) {
+ var layerName = attributes.layers[i][0];
+ if (typeof(merged[layerName]) == 'undefined') {
+ merged[layerName] = attributes[layerName];
+ } else {
+ var newValues = attributes[layerName].values;
+ for (var v = 0; v < newValues.length; v++) {
+ merged[layerName].values.push(newValues[v]);
+ merged[layerName].numelements++;
+ }
+ }
+ }
+ return merged;
+ },
+
processSelectedExtendedFeatureInfo: function(r, mergeSelection) {
var o = Fusion.parseJSON(r.responseText);
var sel = new Fusion.SimpleSelectionObject(o);
var attributes = this.convertExtendedFeatureInfo(o);
- var selText = sel.getSelectionXml();
if (mergeSelection == true)
{
sel.merge(this.previousSelection);
+ attributes = this.mergeAttributes(attributes, this.previousAttributes);
}
+ var selText = sel.getSelectionXml();
this.previousSelection = sel;
//Because the QUERYMAPFEATURES 2.6.0 response contains mostly everything we need, we cut down
//on lots of async request ping-pong. So we can just update the selection image and notify any
//interested parties of the new selection attributes
if (selText != "" && selText != null) {
this.previousAttributes = attributes;
- this.updateMapSelection(selText, false);
- this.processSelectedFeaturePropertiesNode(attributes);
+ this.updateMapSelection(selText, false, mergeSelection);
} else {
- this.previousAttributes = null;
- this.clearSelection();
+ //Only clear if we're not merging an empty selection
+ if (mergeSelection == false) {
+ this.previousAttributes = null;
+ this.clearSelection();
+ }
}
this.mapWidget._removeWorker();
},
More information about the fusion-commits
mailing list