← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1922: (GIS) Map layer bug fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 1922 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-05-28 14:13:22 +0200
message:
  (GIS) Map layer bug fixed.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.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-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-05-27 15:24:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-05-28 12:02:48 +0000
@@ -68,17 +68,31 @@
             params: { type: map_layer_type_baselayer },
             method: 'POST',
             success: function(r) {
-                var mapLayers = Ext.util.JSON.decode(r.responseText).mapLayers;
-                for (var i = 0; i < mapLayers.length; i++) {
-                    MAP.addLayers([
-                        new OpenLayers.Layer.WMS(
-                            mapLayers[i].name,
-                            mapLayers[i].mapSource,
-                            {layers: mapLayers[i].layer}
-                        )
-                    ]);
-                    MAP.layers[MAP.layers.length-1].setVisibility(false);
-                }
+                var mapLayers = Ext.util.JSON.decode(r.responseText).mapLayers;
+				
+				if (mapLayers.length > 0) {
+					for (var i = 0; i < mapLayers.length; i++) {
+						MAP.addLayers([
+							new OpenLayers.Layer.WMS(
+								mapLayers[i].name,
+								mapLayers[i].mapSource,
+								{layers: mapLayers[i].layer}
+							)
+						]);
+						MAP.layers[MAP.layers.length-1].setVisibility(false);
+					}
+				}
+				else {
+					MAP.addLayers([
+						new OpenLayers.Layer.WMS(
+							'World',
+							'http://labs.metacarta.com/wms/vmap0',
+							{layers: 'basic'}
+						)
+					]);
+					
+					MAP.getLayersByName('World')[0].setVisibility(false);
+				}
             }
         });
     }