← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18752: GIS offline fix.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18752 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 16:51:22 +0200
message:
  GIS offline fix.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-03-30 14:18:36 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-03-30 14:50:07 +0000
@@ -1867,14 +1867,19 @@
 			visibleLayer = function() {
                 return window.google ? layers.googleStreets : layers.openStreetMap;
             }(),
-			orderedLayers = gis.olmap.layers.reverse();
+			orderedLayers = gis.olmap.layers.reverse(),
+            layerIsVisibleLayer;
 
         // gm first
-        orderedLayers.push(orderedLayers.shift());
-        orderedLayers.push(orderedLayers.shift());
+        for (var i = 0; i < 2; i++) {
+            if (Ext.Array.contains(['googleStreets', 'googleHybrid'], orderedLayers[0].id)) {
+                orderedLayers.push(orderedLayers.shift());
+            }
+        }
 
-		for (var i = 0; i < orderedLayers.length; i++) {
+		for (var i = 0, layerIsVisibleLayer; i < orderedLayers.length; i++) {
 			layer = orderedLayers[i];
+            layerIsVisibleLayer = Ext.isObject(visibleLayer) && layer.id === visibleLayer.id;
 
 			item = Ext.create('Ext.ux.panel.LayerItemPanel', {
 				cls: 'gis-container-inner',
@@ -1882,17 +1887,19 @@
 				layer: layer,
 				text: layer.name,
 				imageUrl: 'images/' + layer.id + '_14.png',
-				value: layer.id === visibleLayer.id && window.google ? true : false,
+				value: layerIsVisibleLayer && window.google ? true : false,
 				opacity: layer.layerOpacity,
 				defaultOpacity: layer.layerOpacity,
-				numberFieldDisabled: layer.id !== visibleLayer.id
+				numberFieldDisabled: !layerIsVisibleLayer
 			});
 
 			layer.item = item;
 			items.push(layer.item);
 		}
 
-		visibleLayer.item.setValue(!!window.google);
+        if (visibleLayer) {
+            visibleLayer.item.setValue(!!window.google);
+        }
 
         panel = Ext.create('Ext.panel.Panel', {
 			renderTo: 'layerItems',
@@ -9474,7 +9481,7 @@
                 obj = GIS_GM.array[i];
 
                 if (obj) {
-                    console.log("Running queue obj " + (i + 1));
+                    console.log("GM running queue obj " + (i + 1));
                     obj.fn.call(obj.scope);
                 }
             }