changeset 270:3a5d51c60e40

Open Map in new Window
author fknauft
date Fri, 27 Jan 2012 20:02:41 +0100
parents 442c1c3e6f8d
children d1b43624cc63 9b7db308d2e6
files gis_gui/blocks/map.js gis_gui/blocks/map_newwindow.html.pt
diffstat 2 files changed, 53 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/gis_gui/blocks/map.js	Fri Jan 27 12:15:29 2012 +0100
+++ b/gis_gui/blocks/map.js	Fri Jan 27 20:02:41 2012 +0100
@@ -56,8 +56,7 @@
         $(be).find(".map_newwindow_button").click(function () {
             console.debug("map in new window");
             params = block.readMapParams();
-            paramsString=JSON.stringify(params);
-            var newWindow = window.open("blocks/map_newwindow.html?map_params="+paramsString);
+            var newWindow = window.open("blocks/map_newwindow.html?map_id="+params.id);
             //map=block.updateMap(newWindow.document.getElementById("map_box"),params);
         });
         
--- a/gis_gui/blocks/map_newwindow.html.pt	Fri Jan 27 12:15:29 2012 +0100
+++ b/gis_gui/blocks/map_newwindow.html.pt	Fri Jan 27 20:02:41 2012 +0100
@@ -1,5 +1,5 @@
 <html xmlns="http://www.w3.org/1999/xhtml"
-  tal:define="mapParams python:request.get('map_params',None)">
+  tal:define="mapId python:request.get('map_id',None)">
   <head>
     <title tal:content="template/title">Map Points in Time</title>
     <script type="text/javascript" language="JavaScript" src="lib/jquery-1.4.2.js"> </script>
@@ -8,21 +8,57 @@
     <script type="text/javascript" language="JavaScript" src="lib/jquery.clickmenu.pack.js"> </script>
     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
     <script type="text/javascript" language="JavaScript" >
-     
- 	function updateMap(elem,map_params) {
-    
+ 
+    function  loadListOfItems(storeTag,storeType) {
+    	var url = "../db/RESTjson/db/public/gui_objects/"+escape(storeTag)+"/"+storeType+"?recursive=true";
+     	data_ret= jQuery.get(url, function(data) {
+            var ret;
+            data = JSON.parse(data);
+            for (var i=0; i < data.length; i++) {
+                var key = data[i].key;
+                var val = data[i].val;
+               // var name = val.name;
+               // console.debug("map",i," key=",key," value=",name);
+               // ret.append('<option value="'+key+'">'+name+'<'+'/option>');
+                };
+            return data; 
+        }); 
+        return data_ret;
+    } 
+ 	function initialize(map_id) {
+ 	    var data;
+        data=loadListOfItems("test1","map");
+        var statusText;
+        while (statusText!="OK"){
+	        try{
+	        	statusText=data.statusText;
+	            statusText="OK";
+	            }
+	        catch(err){
+	        	statusText="";
+	        	}
+        };
+     	var data_string = data.responseText;	    
+ 	    data=JSON.parse(data_string);	
+        var params;
+        for (var i=0; i < data.length; i++) {
+                var key = data[i].key;
+                var val = data[i].val;
+                if (key = map_id) {
+                	params= val;
+                	break;
+                }
+        };
 	    //************
-	    console.debug("updateMap:", elem, ", ", map_params);
+	    console.debug("initialize:" , map_id);
 	   //*************
 	
-		if (elem == null) {
-	        elem = this.element;
-	    }
-	    if (map_params == null) {
-	        map_params = this.params;
-	    }
+		var elem = document.getElementById("map_box");
+		var map_params;
+	    map_params = params;
+	  
 	    // update and draw the google map
-	    var le = $(elem).find(".map_box").get(0);
+	    var le = $(elem).get(0);
 	    // create empty map
 	    
 	    if (google != null) {
@@ -84,33 +120,15 @@
 	    return map;
 	};
 	
-    function loadListOfItems(storeTag,storeType,callback) {
-        // loads list of id and type objects and executes callback function
-        var url = "../db/RESTjson/db/public/gui_objects/"+escape(storeTag)+"/"+storeType+"?recursive=true";
-
-	    //************
-	    console.debug("jsonUrl:", url);
-	   //*************
-
-        jQuery.getJSON(url,callback);   
-
-	    //************
-	    console.debug("jsoncallback:", callback);
-	   //*************
-    };
     </script>
 
     <link href="lib/clickmenu.css"  rel="stylesheet" content="text/css"/>
     <link href="lib/blocks.css"  rel="stylesheet" content="text/css"/>
     <link href="lib/map.css"  rel="stylesheet" content="text/css"/>
   </head>
-  <body tal:attributes="onload string:updateMap($here,'$mapParams')" >
-   <tal:block metal:use-macro="here/template/macros/module">
-    <tal:block metal:fill-slot="content">
-  
-      <div class="map_box">[loading...]</div>
-
-    </tal:block>
-   </tal:block>
+  <body tal:attributes="onload string:initialize('$mapId')" >
+      <div class="content">
+      	<div id="map_box">[loading...]</div>
+      </div>
   </body>
 </html>
\ No newline at end of file