← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2971: (GIS) Google Maps base layers added. Note that GM API keys are valid for 'a single directory or d...

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2971 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-03 16:01:33 +0100
message:
  (GIS) Google Maps base layers added. Note that GM API keys are valid for 'a single directory or domain'.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
  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/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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/index.html'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html	2011-01-20 23:18:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html	2011-03-03 14:42:07 +0000
@@ -85,6 +85,9 @@
 		
             <!-- UX -->
             <script type="text/javascript" src="../resources/openlayers-ux/newSelectFeature.js"></script>
+			
+		<!-- Google Maps API -->
+		<script src="http://maps.google.com/maps?file=api&amp;v=3&amp;sensor=false&amp;key=ABQIAAAAut6AhySExnYIXm5s2OFIkxRKNzJ-_9njnryRTbvC6CtrS4sRvRREWnxwlZUa630pLuPf3nD9i4fq9w"; type="text/javascript"></script>
         
         <!-- GeoExt -->
         <script type="text/javascript" src="../resources/geoext/script/GeoExt.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-02-25 14:14:20 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-03-03 14:42:07 +0000
@@ -280,10 +280,26 @@
     setKeepPosition: function(cb) {
         cb.keepPosition = !cb.keepPosition ? true : cb.keepPosition;
     },
- 
-    getTransformedPointByXY: function(x, y) {
-		var p = new OpenLayers.Geometry.Point(parseFloat(x), parseFloat(y));
-        return p.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+    
+    mergeSvg: function(str, ext) {
+        if (ext.length) {
+            str = str || '<svg>';
+            for (var i = 0; i < ext.length; i++) {
+                str = str.replace('</svg>');
+                ext[i] = ext[i].substring(ext[i].indexOf('>')+1);
+                str += ext[i];
+            }
+        }
+        return str;
+    },
+    
+    getOverlaysSvg: function(overlays) {
+        if (overlays.length) {
+            for (var i = 0; i < overlays.length; i++) {
+                overlays[i] = document.getElementById(overlays[i].svgId).parentNode.innerHTML;
+            }
+        }
+        return overlays;
     },
 
     getTransformedFeatureArray: function(features) {
@@ -294,6 +310,11 @@
         }
         return features;
     },
+ 
+    getTransformedPointByXY: function(x, y) {
+		var p = new OpenLayers.Geometry.Point(parseFloat(x), parseFloat(y));
+        return p.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+    },
     
     createOverlay: function(name, fillColor, fillOpacity, strokeColor, strokeWidth, url) {
         return new OpenLayers.Layer.Vector(name, {
@@ -314,43 +335,6 @@
         });
     },
     
-    setOpacityByLayerType: function(type, opacity) {
-        for (var i = 0; i < G.vars.map.layers.length; i++) {
-            if (G.vars.map.layers[i].layerType == type) {
-                G.vars.map.layers[i].setOpacity(opacity);
-            }
-        }
-    },
-    
-    setZIndexByLayerType: function(type, index) {
-        for (var i = 0; i < G.vars.map.layers.length; i++) {
-            if (G.vars.map.layers[i].layerType == type) {
-                G.vars.map.layers[i].setZIndex(index);
-            }
-        }
-    },
-    
-    getVectorLayers: function() {
-        var layers = [];
-        for (var i = 0; i < G.vars.map.layers.length; i++) {
-            if (G.vars.map.layers[i].layerType == G.conf.map_layer_type_thematic ||
-            G.vars.map.layers[i].layerType == G.conf.map_layer_type_overlay) {
-                layers.push(G.vars.map.layers[i]);
-            }
-        }
-        return layers;
-    },
-    
-    getLayersByType: function(type) {
-        var layers = [];
-        for (var i = 0; i < G.vars.map.layers.length; i++) {
-            if (G.vars.map.layers[i].layerType == type) {
-                layers.push(G.vars.map.layers[i]);
-            }
-        }
-        return layers;
-    },
-    
     getVisibleLayers: function(layers) {
         var vLayers = [];
         for (var i = 0; i < layers.length; i++) {
@@ -361,25 +345,41 @@
         return vLayers;
     },
     
-    mergeSvg: function(str, ext) {
-        if (ext.length) {
-            str = str || '<svg>';
-            for (var i = 0; i < ext.length; i++) {
-                str = str.replace('</svg>');
-                ext[i] = ext[i].substring(ext[i].indexOf('>')+1);
-                str += ext[i];
-            }
-        }
-        return str;
-    },
-    
-    getOverlaysSvg: function(overlays) {
-        if (overlays.length) {
-            for (var i = 0; i < overlays.length; i++) {
-                overlays[i] = document.getElementById(overlays[i].svgId).parentNode.innerHTML;
-            }
-        }
-        return overlays;
+    getVectorLayers: function() {
+        var layers = [];
+        for (var i = 0; i < G.vars.map.layers.length; i++) {
+            if (G.vars.map.layers[i].layerType == G.conf.map_layer_type_thematic ||
+            G.vars.map.layers[i].layerType == G.conf.map_layer_type_overlay) {
+                layers.push(G.vars.map.layers[i]);
+            }
+        }
+        return layers;
+    },
+    
+    getLayersByType: function(type) {
+        var layers = [];
+        for (var i = 0; i < G.vars.map.layers.length; i++) {
+            if (G.vars.map.layers[i].layerType == type) {
+                layers.push(G.vars.map.layers[i]);
+            }
+        }
+        return layers;
+    },
+    
+    setZIndexByLayerType: function(type, index) {
+        for (var i = 0; i < G.vars.map.layers.length; i++) {
+            if (G.vars.map.layers[i].layerType == type) {
+                G.vars.map.layers[i].setZIndex(index);
+            }
+        }
+    },
+    
+    setOpacityByLayerType: function(type, opacity) {
+        for (var i = 0; i < G.vars.map.layers.length; i++) {
+            if (G.vars.map.layers[i].layerType == type) {
+                G.vars.map.layers[i].setOpacity(opacity);
+            }
+        }
     },
     
     findArrayValue: function(array, value) {

=== 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	2011-03-01 12:47:47 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2011-03-03 14:42:07 +0000
@@ -378,18 +378,28 @@
     pointLayer.layerType = G.conf.map_layer_type_thematic;
     G.vars.map.addLayer(pointLayer);
     
-    /* Init base layers */	
-    var osmarender = new OpenLayers.Layer.OSM.Osmarender("OSM Osmarender");
-    osmarender.layerType = G.conf.map_layer_type_baselayer;
-    G.vars.map.addLayer(osmarender);
-    
-    var mapnik = new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik");
-    mapnik.layerType = G.conf.map_layer_type_baselayer;
-    G.vars.map.addLayer(mapnik);
-    
-    var cyclemap = new OpenLayers.Layer.OSM.CycleMap("OSM CycleMap");
-    cyclemap.layerType = G.conf.map_layer_type_baselayer;
-    G.vars.map.addLayer(cyclemap);
+    /* Init base layers */
+	var gm_normal = new OpenLayers.Layer.Google("GM Default", {
+		type: G_NORMAL_MAP,
+		sphericalMercator: true,
+		maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
+		numZoomLevels: 21
+	});
+	gm_normal.layerType = G.conf.map_layer_type_baselayer;
+	G.vars.map.addLayer(gm_normal);
+	
+	var gm_hybrid = new OpenLayers.Layer.Google("GM Hybrid", {
+		type: G_HYBRID_MAP,
+		sphericalMercator: true,
+		maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
+		numZoomLevels: 21
+	});
+	gm_hybrid.layerType = G.conf.map_layer_type_baselayer;
+	G.vars.map.addLayer(gm_hybrid);
+	
+    var osm = new OpenLayers.Layer.OSM.Osmarender("OpenStreetMap");
+    osm.layerType = G.conf.map_layer_type_baselayer;
+    G.vars.map.addLayer(osm);
     
     /* Init overlays */
 	function addOverlaysToMap(init) {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-03-01 10:52:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-03-03 14:42:07 +0000
@@ -1432,8 +1432,8 @@
             
             if (this.mapView) {
                 if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) {
-                    var p = G.util.getTransformedPointByXY(this.mapView.longitude, this.mapView.latitude);
-                    G.vars.map.setCenter(new OpenLayers.LonLat(p.x, p.y), this.mapView.zoom);
+                    var point = G.util.getTransformedPointByXY(this.mapView.longitude, this.mapView.latitude);
+                    G.vars.map.setCenter(new OpenLayers.LonLat(point.x, point.y), this.mapView.zoom);
                 }
                 else {
                     G.vars.map.zoomToExtent(this.layer.getDataExtent());

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-02-28 15:04:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-03-03 14:42:07 +0000
@@ -1419,8 +1419,8 @@
 
             if (this.mapView) {
                 if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) {
-                    var p = G.util.getTransformedPointByXY(this.mapView.longitude, this.mapView.latitude);
-                    G.vars.map.setCenter(new OpenLayers.LonLat(p.x, p.y), this.mapView.zoom);
+                    var point = G.util.getTransformedPointByXY(this.mapView.longitude, this.mapView.latitude);
+                    G.vars.map.setCenter(new OpenLayers.LonLat(point.x, point.y), this.mapView.zoom);
                 }
                 else {
                     G.vars.map.zoomToExtent(this.layer.getDataExtent());


Follow ups