Mercurial > hg > ChinaGisRestApi
comparison gis_gui/blocks/map_newwindow.html.pt @ 268:f25ee0424ce6
Open Map in new Window
author | fknauft |
---|---|
date | Fri, 27 Jan 2012 09:43:40 +0100 |
parents | 0a1dee507612 |
children | 3a5d51c60e40 |
comparison
equal
deleted
inserted
replaced
267:260ec888fe15 | 268:f25ee0424ce6 |
---|---|
1 <html> | 1 <html xmlns="http://www.w3.org/1999/xhtml" |
2 tal:define="mapParams python:request.get('map_params',None)"> | |
2 <head> | 3 <head> |
3 <title tal:content="template/title">Map Points in Time</title> | 4 <title tal:content="template/title">Map Points in Time</title> |
4 <script language="JavaScript" src="lib/jquery-1.4.min.js"> </script> | 5 <script type="text/javascript" language="JavaScript" src="lib/jquery-1.4.2.js"> </script> |
5 <script language="JavaScript" src="lib/blocks.js"> </script> | 6 <script type="text/javascript" language="JavaScript" src="lib/blocks.js"> </script> |
6 <script language="JavaScript" src="lib/jquery.clickmenu.pack.js"> </script> | 7 <script type="text/javascript" language="JavaScript" src="lib/map.js"> </script> |
8 <script type="text/javascript" language="JavaScript" src="lib/jquery.clickmenu.pack.js"> </script> | |
9 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | |
10 <script type="text/javascript" language="JavaScript" > | |
11 | |
12 function updateMap(elem,map_params) { | |
13 | |
14 //************ | |
15 console.debug("updateMap:", elem, ", ", map_params); | |
16 //************* | |
17 | |
18 if (elem == null) { | |
19 elem = this.element; | |
20 } | |
21 if (map_params == null) { | |
22 map_params = this.params; | |
23 } | |
24 // update and draw the google map | |
25 var le = $(elem).find(".map_box").get(0); | |
26 // create empty map | |
27 | |
28 if (google != null) { | |
29 var latlng = new google.maps.LatLng(29, 116); | |
30 var mapOpts = { | |
31 zoom: 2, | |
32 center: latlng, | |
33 mapTypeId: google.maps.MapTypeId.TERRAIN, | |
34 scaleControl: true | |
35 }; | |
36 var map = new google.maps.Map(le, mapOpts); | |
37 console.debug("new google map=",map," on el=",le); | |
38 } | |
39 // add the layers | |
40 var layerList = map_params.map_layers; | |
41 for (var i = 0; i < layerList.length; i++) { | |
42 if (!layerList[i].display) { | |
43 continue; | |
44 } | |
45 var params = layerList[i].layer; | |
46 var paramstr = "format=KML_URL"; | |
47 if (params.position_field && params.position_field != "Default") { | |
48 paramstr += "&gis_id_field="+params.position_field; | |
49 } | |
50 if (params.color_field != "Default") { | |
51 paramstr += "&color_field="+params.color_field; | |
52 } | |
53 if (params.geometry_field != "Default") { | |
54 paramstr += "&geometry_field="+params.geometry_field; | |
55 } | |
56 if (params.sort_field != "Default") { | |
57 paramstr += "&sort_field="+params.sort_field; | |
58 } | |
59 if (params.connect_line) { | |
60 paramstr += "&connect_line="+params.connect_line; | |
61 } | |
62 var layerurl = "../db/RESTdb/db/public/" + escape(params.table) + "?" + paramstr; | |
63 jQuery.get(layerurl, function (data, textStatus, XMLHttpRequest) { | |
64 // function after load kml url finished | |
65 console.debug("kml url loaded! this=", this ); | |
66 console.debug(" data=", data ); | |
67 console.debug(" data type=", typeof(data)); | |
68 if (typeof(data) == "string") { | |
69 var kmlURL = data; | |
70 } else { | |
71 // broken, what now? | |
72 return; | |
73 } | |
74 // render layer | |
75 if (google != null) { | |
76 var newMarker=new google.maps.KmlLayer(kmlURL); | |
77 console.debug("new marker layer no",i,"=",newMarker); | |
78 console.debug(" map=",map); | |
79 newMarker.setMap(map); | |
80 console.debug("Map-Update finished"); | |
81 } | |
82 }); | |
83 } | |
84 return map; | |
85 }; | |
86 | |
87 function loadListOfItems(storeTag,storeType,callback) { | |
88 // loads list of id and type objects and executes callback function | |
89 var url = "../db/RESTjson/db/public/gui_objects/"+escape(storeTag)+"/"+storeType+"?recursive=true"; | |
90 | |
91 //************ | |
92 console.debug("jsonUrl:", url); | |
93 //************* | |
94 | |
95 jQuery.getJSON(url,callback); | |
96 | |
97 //************ | |
98 console.debug("jsoncallback:", callback); | |
99 //************* | |
100 }; | |
101 </script> | |
7 | 102 |
8 <link href="lib/clickmenu.css" rel="stylesheet" content="text/css"/> | 103 <link href="lib/clickmenu.css" rel="stylesheet" content="text/css"/> |
9 <link href="lib/blocks.css" rel="stylesheet" content="text/css"/> | 104 <link href="lib/blocks.css" rel="stylesheet" content="text/css"/> |
105 <link href="lib/map.css" rel="stylesheet" content="text/css"/> | |
10 </head> | 106 </head> |
11 <body> | 107 <body tal:attributes="onload string:updateMap($here,'$mapParams')" > |
108 <tal:block metal:use-macro="here/template/macros/module"> | |
109 <tal:block metal:fill-slot="content"> | |
110 | |
111 <div class="map_box">[loading...]</div> | |
12 | 112 |
13 <div class="map_box" id="map_box">[loading...]</div> | 113 </tal:block> |
114 </tal:block> | |
14 </body> | 115 </body> |
15 </html> | 116 </html> |