[fusion-commits] r2759 - in sandbox/describeruntimemap: layers/MapGuide lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Sun Aug 4 07:42:20 PDT 2013
Author: jng
Date: 2013-08-04 07:42:20 -0700 (Sun, 04 Aug 2013)
New Revision: 2759
Modified:
sandbox/describeruntimemap/layers/MapGuide/MapGuide.js
sandbox/describeruntimemap/lib/MGBroker.js
Log:
Use DESCRIBERUNTIMEMAP for Fusion.Layers.MapGuide.reloadMap() if support is available (bUseNativeServices == true). This will allow us to bypass the LoadMap.php/LoadScaleRanges.php chain for a full legend refresh as well.
Modified: sandbox/describeruntimemap/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/describeruntimemap/layers/MapGuide/MapGuide.js 2013-08-04 13:46:27 UTC (rev 2758)
+++ sandbox/describeruntimemap/layers/MapGuide/MapGuide.js 2013-08-04 14:42:20 UTC (rev 2759)
@@ -669,17 +669,27 @@
var oldLayers = $A(this.aLayers);
this.aLayers = [];
- var sl = Fusion.getScriptLanguage();
- var loadmapScript = 'layers/' + this.arch + '/' + sl + '/LoadMap.' + sl;
+ if (this.bUseNativeServices) {
+ var features = (1 | 2 | 4); //We want the whole lot
+ var r = new Fusion.Lib.MGRequest.MGDescribeRuntimeMap(this._sMapname, features, 25);
+ r.setParams({
+ iconFormat: "GIF",
+ session: this.getSessionID()
+ });
+ Fusion.oBroker.dispatchRequest(r, OpenLayers.Function.bind(this.onRuntimeMapReloaded, this, oldLayers));
+ } else {
+ var sl = Fusion.getScriptLanguage();
+ var loadmapScript = 'layers/' + this.arch + '/' + sl + '/LoadMap.' + sl;
- var sessionid = this.getSessionID();
+ var sessionid = this.getSessionID();
- var params = {'mapname': this._sMapname, 'session': sessionid};
- var options = {
- onSuccess: OpenLayers.Function.bind(this.mapReloaded,this,oldLayers),
- onException: OpenLayers.Function.bind(this.reloadFailed, this),
- parameters: params};
- Fusion.ajaxRequest(loadmapScript, options);
+ var params = {'mapname': this._sMapname, 'session': sessionid};
+ var options = {
+ onSuccess: OpenLayers.Function.bind(this.mapReloaded,this,oldLayers),
+ onException: OpenLayers.Function.bind(this.reloadFailed, this),
+ parameters: params};
+ Fusion.ajaxRequest(loadmapScript, options);
+ }
},
reloadFailed: function(r) {
@@ -746,6 +756,31 @@
}
},
+ onRuntimeMapReloaded: function(oldLayers, r) {
+ if (r.status == 200) {
+ var json = Fusion.parseJSON(r.responseText);
+ var co = this.convertResponse(json);
+ var o = co.LoadMap;
+ this.parseMapLayersAndGroups(o);
+ //Need to wait for the right event to trigger loadScaleRanges, so stash our
+ //prepared result for when it comes
+ this._initScaleRanges = co.LoadScaleRanges;
+ for (var i=0; i<this.aLayers.length; ++i) {
+ var newLayer = this.aLayers[i];
+ for (var j=0; j<oldLayers.length; ++j){
+ if (oldLayers[j].uniqueId == newLayer.uniqueId) {
+ newLayer.selectedFeatureCount = oldLayers[j].selectedFeatureCount;
+ newLayer.noCache = oldLayers[j].noCache;
+ break;
+ }
+ }
+ }
+ this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
+ this.drawMap();
+ }
+ this.mapWidget._removeWorker();
+ },
+
//TBD: this function not yet converted for OL
mapReloaded: function(oldLayers,r) {
if (r.status == 200) {
Modified: sandbox/describeruntimemap/lib/MGBroker.js
===================================================================
--- sandbox/describeruntimemap/lib/MGBroker.js 2013-08-04 13:46:27 UTC (rev 2758)
+++ sandbox/describeruntimemap/lib/MGBroker.js 2013-08-04 14:42:20 UTC (rev 2759)
@@ -344,6 +344,35 @@
});
/****************************************************************************
+ * Class: Fusion.Lib.MGRequest.MGDescribeRuntimeMap
+ *
+ * encapsulate a request to the server to create a new runtime map (and session if required)
+ * on the server
+ *
+ * Inherits from:
+ * - <Fusion.Lib.MGRequest>
+ */
+Fusion.Lib.MGRequest.MGDescribeRuntimeMap = OpenLayers.Class(Fusion.Lib.MGRequest, {
+ /**
+ * Constructor: Fusion.Lib.MGRequest.MGCreateRuntimeMap
+ *
+ * initialize a new instance of Fusion.Lib.MGRequest.MGCreateRuntimeMap
+ */
+ initialize: function(mapName, features, iconsPerScaleRange) {
+ this.initializeRequest();
+ this.setParams({
+ operation: "DESCRIBERUNTIMEMAP",
+ mapname: mapName,
+ requestedfeatures: features,
+ iconsperscalerange: iconsPerScaleRange,
+ format: "application/json",
+ version: "2.6.0"
+ });
+ }
+});
+
+
+/****************************************************************************
* Class: Fusion.Lib.MGRequest.MGCopyResource
*
* encapsulate a request to the server to copy a resource.
More information about the fusion-commits
mailing list