[fusion-commits] r2706 - in sandbox/createruntimemap: layers/MapGuide lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Sat May 18 03:16:16 PDT 2013
Author: jng
Date: 2013-05-18 03:16:16 -0700 (Sat, 18 May 2013)
New Revision: 2706
Modified:
sandbox/createruntimemap/layers/MapGuide/MapGuide.js
sandbox/createruntimemap/lib/fusion.js
Log:
Ensure Fusion.Layer.MapGuide has access to the site version to do the native service support check under all possible initialization scenarios
Modified: sandbox/createruntimemap/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/createruntimemap/layers/MapGuide/MapGuide.js 2013-05-18 09:44:19 UTC (rev 2705)
+++ sandbox/createruntimemap/layers/MapGuide/MapGuide.js 2013-05-18 10:16:16 UTC (rev 2706)
@@ -124,6 +124,10 @@
this.noCache = true;
this.oLayersOLTile = [];
+ if (Fusion.siteVersion) {
+ this.siteVersion = Fusion.siteVersion;
+ this.checkNativeServiceSupport();
+ }
var sid = Fusion.sessionId;
if (sid) {
this.session[0] = sid;
@@ -150,6 +154,24 @@
}
},
+ checkNativeServiceSupport: function() {
+ //NOTE: Using native services may cause a slight (but not too much) delay in any requests to PHP scripts
+ //that use layer property mappings as they will be lazy loaded due to us not calling LoadMap.php, which
+ //would've pre-cached such information. but we get much better map init performance
+ this.bUseNativeServices = false;
+ var vMajor = this.siteVersion[0];
+ var vMinor = this.siteVersion[1];
+ if (vMajor > 2) { // 3.0 or higher
+ this.bUseNativeServices = true;
+ } else {
+ if (vMajor == 2) { // 2.x
+ if (vMinor >= 6) { // >= 2.6
+ this.bUseNativeServices = true;
+ }
+ }
+ }
+ },
+
createSessionCB: function(xhr) {
if (xhr.status == 200) {
var o = Fusion.parseJSON(xhr.responseText);
@@ -163,21 +185,7 @@
parseInt(bits[2]),
parseInt(bits[3])
);
- //NOTE: Using native services may cause a slight (but not too much) delay in any requests to PHP scripts
- //that use layer property mappings as they will be lazy loaded due to us not calling LoadMap.php, which
- //would've pre-cached such information. but we get
- this.bUseNativeServices = false;
- var vMajor = this.siteVersion[0];
- var vMinor = this.siteVersion[1];
- if (vMajor > 2) { // 3.0 or higher
- this.bUseNativeServices = true;
- } else {
- if (vMajor == 2) { // 2.x
- if (vMinor >= 6) { // >= 2.6
- this.bUseNativeServices = true;
- }
- }
- }
+ this.checkNativeServiceSupport();
this.session[0] = o.sessionId;
var acceptLang = o.acceptLanguage.split(',');
//IE - en-ca,en-us;q=0.8,fr;q=0.5,fr-ca;q=0.3
Modified: sandbox/createruntimemap/lib/fusion.js
===================================================================
--- sandbox/createruntimemap/lib/fusion.js 2013-05-18 09:44:19 UTC (rev 2705)
+++ sandbox/createruntimemap/lib/fusion.js 2013-05-18 10:16:16 UTC (rev 2706)
@@ -1605,38 +1605,65 @@
}
xhr.open("GET", url, false);
xhr.send(null);
- var o;
- eval('o='+xhr.responseText);
+ var o = Fusion.parseJSON(xhr.responseText);
Fusion.sessionId = o.sessionId;
+ var version = o.siteVersion;
+ var bits = version.split('.');
+ Fusion.siteVersion = new Array(parseInt(bits[0]),
+ parseInt(bits[1]),
+ parseInt(bits[2]),
+ parseInt(bits[3])
+ );
}
var appDefUrl = Fusion.getQueryParam('ApplicationDefinition');
- if(appDefUrl && (
+ if (appDefUrl && (
appDefUrl.indexOf('Library') == 0 ||
- appDefUrl.indexOf('Session') == 0)){
+ appDefUrl.indexOf('Session') == 0)) {
+
+ var fetchAppDef = function(appDefUrl, sessionId) {
+ var xhr = new getXmlHttpRequest();
+ var mapAgentUrl = getAgentUrl();
+ xhr.open("GET", mapAgentUrl + "?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml&SESSION="+ sessionId, false);
+ xhr.send(null);
+ var appDefXML = xhr.responseXML.documentElement;
+
+ if (appDefXML) {
+ var googleElement = appDefXML.getElementsByTagName("GoogleScript")[0];
+ var yahooElement = appDefXML.getElementsByTagName("YahooScript")[0];
+ var veElement = appDefXML.getElementsByTagName("VirtualEarthScript")[0];
+ var osmElement = appDefXML.getElementsByTagName("OpenStreetMapScript")[0];
+
+ addElement(googleElement);
+ addElement(yahooElement);
+ addElement(veElement);
+ addElement(osmElement);
+ }
+ };
+
+ var getSiteVersion = function(sessionId) {
+ var xhr = new getXmlHttpRequest();
+ var mapAgentUrl = getAgentUrl();
+ xhr.open("GET", mapAgentUrl + "?OPERATION=GETSITEVERSION&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&SESSION="+ sessionId, false);
+ xhr.send(null);
+ var verXML = xhr.responseXML.documentElement;
+ var el = verXML.getElementsByTagName("Version")[0];
+ var version = el.textContent || el.text;
+ var bits = version.split('.');
+ return new Array(parseInt(bits[0]),
+ parseInt(bits[1]),
+ parseInt(bits[2]),
+ parseInt(bits[3]));
+ };
+
var passedSessionId = Fusion.getQueryParam('Session');
- if(passedSessionId == null || passedSessionId == "" ){
+ if (passedSessionId == null || passedSessionId == "" ){
createSessionId(Fusion.getQueryParam("Username"), Fusion.getQueryParam("Password"));
- }else{
+ } else {
Fusion.sessionId = passedSessionId;
+ Fusion.siteVersion = getSiteVersion(passedSessionId);
}
- var xhr = new getXmlHttpRequest();
- var mapAgentUrl = getAgentUrl();
- xhr.open("GET", mapAgentUrl + "?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml&SESSION="+ Fusion.sessionId, false);
- xhr.send(null);
- var appDefXML = xhr.responseXML.documentElement;
-
- if(appDefXML){
- var googleElement = appDefXML.getElementsByTagName("GoogleScript")[0];
- var yahooElement = appDefXML.getElementsByTagName("YahooScript")[0];
- var veElement = appDefXML.getElementsByTagName("VirtualEarthScript")[0];
- var osmElement = appDefXML.getElementsByTagName("OpenStreetMapScript")[0];
-
- addElement(googleElement);
- addElement(yahooElement);
- addElement(veElement);
- addElement(osmElement);
- }
+ fetchAppDef(appDefUrl, Fusion.sessionId);
}
})();
More information about the fusion-commits
mailing list