← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2052: GIS: made export to img slightly more robust

 

------------------------------------------------------------
revno: 2052
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Sat 2010-09-04 07:33:45 +0200
message:
  GIS: made export to img slightly more robust
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-09-03 14:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-04 05:33:45 +0000
@@ -153,6 +153,23 @@
 	return json;
 }
 
+function getSvgDivId(svgChildren) {
+	var svgNode;
+	var svgDivId;
+
+	for (i=0; i<svgChildren.length; i++) {
+		svgNode = svgChildren[i];
+		svgDivId = svgNode.getAttribute('id');		
+
+		while (svgNode.hasChildNodes()) {
+			svgNode = svgNode.firstChild;
+			if ( svgNode.nodeName && svgNode.nodeName == 'path' ) {
+				return svgDivId;
+			}
+		}
+	}
+}
+
 Ext.onReady( function() {
     Ext.BLANK_IMAGE_URL = '../resources/ext/resources/images/default/s.gif';
 	/* Cookie provider */
@@ -611,17 +628,10 @@
 
                     if (vcb && dcb && mcb && lcb) {
                     	var svgChildren = document.getElementById('_OpenLayers_Container').childNodes;
-						var svgDivId = null;
-
-						for (i = 0; i < svgChildren.length; i++) { // Search for div containing SVG
-							svgDivId = svgChildren[i].getAttribute('id');
-							if (svgDivId && svgDivId.indexOf('OpenLayers.Layer.Vector_') != -1) {
-								break;
-							}
-						}
+						var svgDivId = getSvgDivId(svgChildren);
 
 						var svg = document.getElementById(svgDivId).innerHTML;
-						var objectSVGDocument = document.getElementById(svgDivId).childNodes[0];
+						var objectSVGDocument = document.getElementById(svgDivId).firstChild;
 						
                         var viewBox = objectSVGDocument.getAttribute('viewBox');
                         var title = Ext.getCmp('exportimagetitle_tf').getValue();