Mercurial > hg > LGMap
annotate map.js @ 11:389cf726303e
mode=1, and add download.php
author | nylin@mpiwg-berlin.mpg.de |
---|---|
date | Tue, 27 Oct 2015 15:05:07 +0100 |
parents | 8f5635197895 |
children | f17f43f0a63f |
rev | line source |
---|---|
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
1 |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
2 |
0 | 3 //geoserver url |
4 var url="http://geoserver.mpiwg-berlin.mpg.de/geoserver/China_Monograph_Project/ows"; | |
6 | 5 |
0 | 6 //"name": "layer name" |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
7 var overlayArray=[ |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
8 {name:"中國1820省界", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
9 file:"China_Monograph_Project:AD1820ChinaProfPolgon", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
10 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
11 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
12 {name:"中國1820府界", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
13 file:"China_Monograph_Project:AD1820ChinaPrefPolygon", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
14 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
15 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
16 {name:"中國1820省名", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
17 file:"China_Monograph_Project:AD1820ChinaProfPoint", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
18 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
19 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
20 {name:"China 1820 Province", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
21 file:"China_Monograph_Project:AD1820ChinaProfPoint_PY", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
22 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
23 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
24 {name:"中國1820府名", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
25 file:"China_Monograph_Project:AD1820ChinaPrefPoint", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
26 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
27 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
28 {name:"China 1820 Prefecture", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
29 file:"China_Monograph_Project:AD1820ChinaPrefPoint_PY", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
30 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
31 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
32 {name:"中國1820縣市名", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
33 file:"China_Monograph_Project:AD1820ChinaCountyPoints", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
34 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
35 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
36 {name:"China 1820 County", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
37 file:"China_Monograph_Project:AD1820ChinaCountyPoints_PY", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
38 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
39 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
40 {name:"中國1820鄉鎮名", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
41 file:"China_Monograph_Project:AD1820ChinaTownPoint", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
42 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
43 }, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
44 {name:"China 1820 village", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
45 file:"China_Monograph_Project:AD1820ChinaTownPoint_PY", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
46 preload:false |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
47 }, |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
48 {name:"provincial distribution of local monographs", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
49 file:"China_Monograph_Project:monograph_distribution_prov_x", |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
50 preload:false |
0 | 51 }, |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
52 /*{ |
0 | 53 name:"test", |
54 file:"China_Monograph_Project:v5_citas90_pref_pgn_utf", | |
55 preload:false | |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
56 },*/ |
0 | 57 { |
58 name:"provincial capitals", | |
59 file:"China_Monograph_Project:all_monographs_capital_points", | |
60 preload:false | |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
61 } |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
62 ]; |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
63 var datasetArray=[ |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
64 |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
65 {name:"distribution of local monographs", |
0 | 66 file:"./datasets/books_coordinates.csv", |
67 preload:true | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
68 |
0 | 69 }, |
70 { | |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
71 name:"蝗神廟之分佈", |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
72 file:"./datasets/locust_temples.csv", |
0 | 73 preload:false |
74 }]; | |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
75 var backgroundMapArray=[ |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
76 /*{ |
0 | 77 name: 'Barrington Roman Empire', |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
78 url: 'http://pelagios.dme.ait.ac.at/tilesets/imperium/${z}/${x}/${y}.png', |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
79 type:'XYZ', |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
80 attribution: "(c) Barrington Roman Empiry, <a href='http://pelagios.dme.ait.ac.at/maps/greco-roman/'>Pelagios</a>" |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
81 },*/ |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
82 { |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
83 name: '世界地形圖', |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
84 url: 't/world/${z}/${x}/${y}.png', |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
85 type:'XYZ', |
9
e46b45b431a1
enhance China river in zoom level 8 and 9
nylin@mpiwg-berlin.mpg.de
parents:
8
diff
changeset
|
86 attribution: "© mpiwg-berlin, <a href='https://www.mpiwg-berlin.mpg.de'>Max Planck Institute for the History of Science</a>" |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
87 } |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
88 , |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
89 /*,{ |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
90 name: '西元1820年 清朝 行政區', |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
91 url: 'http://wmsproxy.appspot.com/map.jsp?l=China1820-png-${z}-${x}-${y}', |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
92 type:'XYZ', |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
93 attribution: "© NTU CSIE 303 Lab, <a href='http://archimedes.csie.ntu.edu.tw/lab_web1/'>NTU CSIE 303 Lab</a>" |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
94 }*/ |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
95 ]; |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
96 //mpgiwg layers |
11 | 97 if (client_ip.substring(0,9)=="141.14.23") { |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
98 backgroundMapArray.push( |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
99 { |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
100 |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
101 name: '陳正祥–蝗神廟之分佈', |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
102 url: 't/pa-cha/${z}/${x}/${y}.png', |
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
103 type:'XYZ', |
9
e46b45b431a1
enhance China river in zoom level 8 and 9
nylin@mpiwg-berlin.mpg.de
parents:
8
diff
changeset
|
104 attribution: "© 中國文化地理 陳正祥, <a href='https://zh.wikipedia.org/wiki/%E9%99%B3%E6%AD%A3%E7%A5%A5'>wikipedia</a>" |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
105 } |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
106 ); |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
107 } |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
108 |
0 | 109 var colorArray=[{//blue |
110 r1 : 0, | |
111 g1 : 128, | |
112 b1 : 255, | |
113 r0 : 205, | |
114 g0 : 230, | |
115 b0 : 255 | |
116 },{//red | |
117 r1 : 255, | |
118 g1 : 84, | |
119 b1 : 22, | |
120 r0 : 255, | |
121 g0 : 218, | |
122 b0 : 205 | |
123 }, {//purple | |
124 r1 : 132, | |
125 g1 : 0, | |
126 b1 : 255, | |
127 r0 : 231, | |
128 g0 : 205, | |
129 b0 : 255 | |
130 }, {//green | |
131 r1 : 0, | |
132 g1 : 225, | |
133 b1 : 116, | |
134 r0 : 180, | |
135 g0 : 225, | |
136 b0 : 204 | |
137 }, {//yellow | |
138 r1 : 255, | |
139 g1 : 191, | |
140 b1 : 0, | |
141 r0 : 255, | |
142 g0 : 243, | |
143 b0 : 205 | |
144 }]; | |
145 var map, table,timeline,pieChart; | |
146 var urlParameter=new Array(); | |
147 $(document).ready(function(){ | |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
148 |
0 | 149 GeoTemConfig.datasets=[]; |
150 GeoTemConfig.colors=colorArray; | |
151 getUrlParameter(); | |
152 if(urlParameter['name']!=undefined&&urlParameter['file']!=undefined){ //See if this page is referred by search result | |
153 var file="./datasets/"+decodeURI(urlParameter['file']); | |
154 var name=decodeURI(urlParameter['name']); | |
155 var obj={name:name,file:file,preload:true}; | |
156 datasetArray.splice(0,0,obj); | |
157 } | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
158 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
159 // zoe added for incoming json object from LGDataverse |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
160 if (urlParameter['name']!=undefined && urlParameter['file']==undefined && urlParameter['fileId']!=undefined) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
161 var file=undefined; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
162 var name=decodeURI(urlParameter['name']); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
163 var obj={name:name,file:file,preload:true}; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
164 datasetArray.splice(0,0,obj); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
165 }; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
166 // end |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
167 |
0 | 168 initWindowWidget(); |
169 initWidget(); //initial Sebastian's widgets | |
170 initToolbar(); //initial the left side icons | |
171 // Syncronize checkboxes and table widget | |
172 var subscriber; | |
173 Publisher.Subscribe('filterData',subscriber,function(data){ | |
174 $("#datasetContainer input:checkbox").each(function(){ | |
175 var name=$(this).attr("name"); | |
176 var dataset=$.grep(data,function(val,key){ | |
177 return val.label==name; | |
178 }); | |
179 if(dataset.length==0){ | |
180 this.checked=false; | |
181 } | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
182 // zoe added |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
183 if (urlParameter['file']==undefined && urlParameter['fileId']!=undefined && name==urlParameter['name']) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
184 this.checked = true; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
185 this.disabled = true; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
186 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
187 // end |
0 | 188 }); |
189 }); | |
190 $(".windowWidget").hide(); | |
191 $(".windowWidget .windowWidgetBar .visibilityButton").click(); | |
192 | |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
193 // debug by yao |
0 | 194 $("#aboutIcon").click(); |
195 }); | |
196 function getUrlParameter(){ | |
197 //examine the parameter "mode" in the url | |
198 var url=window.location.href; | |
199 var pos=url.indexOf("?"); | |
200 if(pos!=-1){ | |
201 var params=url.substring(pos+1); | |
202 var varArray=params.split("&"); | |
203 for(var i=0; i<varArray.length; i++){ | |
204 pos=varArray[i].indexOf("="); | |
205 var name=varArray[i].substring(0,pos); | |
206 var value=varArray[i].substring(pos+1); | |
207 urlParameter[name]=value; | |
208 /* | |
209 if(name=="mode"){ | |
210 mode=value; | |
211 }*/ | |
212 } | |
213 } | |
214 } | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
215 |
0 | 216 function loadDataset(name,fileName){ |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
217 // zoe added |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
218 if (fileName==undefined) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
219 // Get file json object from POST from LGDataverse by fileId in url |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
220 var fileId = urlParameter['fileId']; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
221 var lgdv_url = lgdataverse_url + "getDatafile?fileId="+fileId; // lgdataverse_url is a global var |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
222 console.log("lgdv_url:"+lgdv_url); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
223 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
224 var fileData = {}; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
225 $.ajax({ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
226 url : lgdataverse_url+"getDatafile", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
227 async : false, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
228 type : 'GET', |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
229 data: 'fileId='+fileId, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
230 dataType: "json", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
231 success: function (data) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
232 console.log("getting file from LGDataverse success!"); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
233 fileData = data; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
234 }, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
235 error: function (data) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
236 console.log("getting file from LGDataverse failed!" + data); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
237 alert("Data "+ urlParameter['name'] +" CANNOT be shown on the map."); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
238 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
239 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
240 }).done(function(result) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
241 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
242 }); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
243 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
244 if (fileData.state == "ok") { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
245 /* |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
246 var json = [ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
247 { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
248 // these fields are required in map |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
249 "description":"20卷 ╱ (民國) 崔正春修 (民國) 尚希寳纂 ╱ 民國十八年鉛印本", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
250 "lat":36.974178, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
251 "lon":115.259262, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
252 "place":"威縣", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
253 // ---- |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
254 "tableContent":{ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
255 // these fields are shown as columns in the table |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
256 "description":"20卷 ╱ (民國) 崔正春修 (民國) 尚希寳纂 ╱ 民國十八年鉛印本", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
257 "name":"(民國) 威縣志", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
258 "place":"威縣", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
259 "testColumn1":"content1", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
260 "testColumn2":"content2", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
261 "testColumn3":"content3", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
262 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
263 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
264 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
265 ]; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
266 */ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
267 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
268 var dataCSVformat = fileData.file.dataString; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
269 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
270 //console.log(dataCSVformat); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
271 var json = GeoTemConfig.convertCsv(dataCSVformat); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
272 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
273 GeoTemConfig.addDataset(new Dataset(GeoTemConfig.loadJson(json),name)); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
274 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
275 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
276 } else { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
277 // zoe end |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
278 |
0 | 279 var csvFile=GeoTemConfig.getCsv(fileName, |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
280 function(json){ |
0 | 281 GeoTemConfig.addDataset(new Dataset(GeoTemConfig.loadJson(json),name)); |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
282 |
0 | 283 //checking the checkbox has to be done here, because if done in the each loop below, it will be unchecked again in the Publisher.Subscribe function. For the Publisher.Subscribe function may be called when the dataset is not yet loaded, which causes dataset.length to be 0 and unchecks the checkbox |
284 $("#datasetContainer input:checkbox[value*='"+fileName+"']").prop("checked",true); | |
285 //rename the column "name" to "title" | |
286 $(".headerLabel").each(function(){ | |
287 if ($(this).html() == "name"){ | |
288 $(this).empty(); | |
289 $(this).html("title"); | |
290 } | |
291 }); | |
292 /*//this is redundant when calling GeoTemConfig.addDataset | |
293 //display in all widgets | |
294 map.display(GeoTemConfig.datasets); | |
295 timeline.display(GeoTemConfig.datasets); | |
296 table.display(GeoTemConfig.datasets); | |
297 pieChart.display(GeoTemConfig.datasets); */ | |
298 } | |
299 ); | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
300 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
301 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
302 |
0 | 303 } |
304 function closeDataset(name,fileName){ | |
305 var idx; | |
306 //find the dataset to close by name | |
307 var data=$.grep(GeoTemConfig.datasets,function(val,key){ | |
308 if(val.label==name){ | |
309 idx=key; | |
310 } | |
311 return val.label==name; | |
312 }); | |
313 //GeoTemConfig.datasets.splice(idx,1); | |
314 GeoTemConfig.removeDataset(idx); | |
315 } | |
316 function initWidget(){ | |
317 var mapElem=document.getElementById("mapContainer"); | |
318 map=new WidgetWrapper(); | |
319 var mapWidget=new MapWidget(map,mapElem,{ | |
320 mapTitle:"", | |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
321 minimumRadius:2, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
322 baseLayer:'世界地形圖', //底圖 |
0 | 323 alternativeMap:backgroundMapArray |
324 }); | |
325 | |
326 var overlayLoaderElem=document.getElementById("overlayLoaderContainer"); | |
327 var overlayLoader=new WidgetWrapper(); | |
328 var overlayLoaderWidget=new OverlayloaderWidget(overlayLoader,overlayLoaderElem); | |
329 overlayLoaderWidget.attachMapWidget(mapWidget); | |
330 //insert overlay checkboxes | |
331 $.each(overlayArray,function(idx,obj){ | |
332 var name=obj.name; | |
333 var file=obj.file; | |
334 var preload=obj.preload; | |
335 var optionObj=$("<div class='option'></div>"); | |
336 $("#overlayContainer").append(optionObj); | |
337 var checkBoxObj=$("<input type='checkbox' name='"+name+"' value='"+file+"'>"); | |
338 checkBoxObj.prop("checked",preload); | |
339 optionObj.append(checkBoxObj); | |
340 var nameObj=$("<div class='label'>"+name+"</div>"); | |
341 optionObj.append(nameObj); | |
342 if(preload){ | |
343 overlayLoaderWidget.overlayLoader.distributeArcGISWMS(url,file); | |
344 } | |
345 }); | |
346 | |
347 $("#overlayContainer input:checkbox").click(function(e){ | |
348 //dirty insertion and deletion, delete all the overlays and insert them in the specified sequence | |
349 //in order to maintain the sequence of overlays, so that the smaller one will always be on top of the bigger ones | |
350 //in the overlayLoader, clicking on the "x" button deletes the overlay. Here deletion is done by triggering the click event rather than deleting the overlay directly | |
351 while($("#overlayLoaderContainer div:last-child a").length!=0){ | |
352 $("#overlayLoaderContainer div a:nth-child(1)").click(); | |
353 } | |
354 | |
355 $("#overlayContainer input:checkbox").each(function(){ | |
356 if($(this).is(":checked")){ | |
357 overlayLoaderWidget.overlayLoader.distributeArcGISWMS(url, | |
358 $(this).val()); | |
359 } | |
360 }); | |
361 //stop the event from propagating, or the list would close every time the user checks an item | |
362 e.stopPropagation(); | |
363 /* | |
364 //normal insertion and deletion | |
365 if($(this).is(":checked")){//selected | |
366 overlayLoaderWidget.overlayLoader.distributeArcGISWMS("http://geoserver.mpiwg-berlin.mpg.de/geoserver/China_Monograph_Project/ows", | |
367 $(this).val()); | |
368 }else{//deselect | |
369 var name=url+" - "+$(this).val(); | |
370 var layerNameArray=$("#overlayLoaderContainer > div:last-child").html().split('<a href="">(x)</a>'); | |
371 var idx=$.inArray(name,layerNameArray); | |
372 $("#overlayLoaderContainer div a:nth-child("+(idx+1)+")").click(); | |
373 }*/ | |
374 }); | |
375 | |
376 | |
377 //insert dataset checkboxes | |
378 $.each(datasetArray,function(idx,obj){ | |
379 var name=obj.name; | |
380 var file=obj.file; | |
381 var preload=obj.preload; | |
382 var optionObj=$("<div class='option'></div>"); | |
383 $("#datasetContainer ").append(optionObj); | |
384 var checkBoxObj=$("<input type='checkbox' name='"+name+"' value='"+file+"'>"); | |
385 optionObj.append(checkBoxObj); | |
386 //checkBoxObj.prop("checked",preload); | |
387 var nameObj=$("<div class='label'>"+name+"</div>"); | |
388 optionObj.append(nameObj); | |
389 if(preload){ | |
390 loadDataset(name,file); | |
391 } | |
392 }); | |
393 $("#datasetContainer input:checkbox").click(function(){ | |
394 /* | |
395 //dirty insertion and deletion, too slow | |
396 while($("#tableContainer .tableTabs").children().length!=0){ | |
397 //console.log($("#tableContainer .tableTabs").children().length); | |
398 //$("#tableContainer .tableTabs .tableTab:nth-child(1) .smallButton")[0].onclick(); | |
399 GeoTemConfig.removeDataset(0); | |
400 } | |
401 | |
402 $("#datasetContainer .content input:checkbox").each(function(){ | |
403 if($(this).is(":checked")){ | |
404 loadDataset($(this).attr("name"),$(this).val()); | |
405 } | |
406 }); | |
407 */ | |
408 if($(this).is(":checked")){//selected | |
409 loadDataset($(this).attr("name"),$(this).val()); | |
410 }else{ | |
411 closeDataset($(this).attr("name"),$(this).val()); | |
412 } | |
413 }); | |
414 var timelineElem=document.getElementById("timelineContainer"); | |
415 timeline=new WidgetWrapper(); | |
416 var timelineWidget=new FuzzyTimelineWidget(timeline,timelineElem,{ | |
417 timelineTitle:"" | |
418 }); | |
419 | |
420 var tableElem=document.getElementById("tableContainer"); | |
421 table=new WidgetWrapper(); | |
422 var tableWidget=new TableWidget(table,tableElem); | |
423 | |
424 var pieChartElem=document.getElementById("pieChartContainer"); | |
425 pieChart=new WidgetWrapper(); | |
426 var pieChartWidget=new PieChartWidget(pieChart,pieChartElem); | |
427 //pieChartWidget.addPieChart(0,"place"); | |
428 } | |
429 function initToolbar(){ | |
11 | 430 var mode=1; |
0 | 431 if(urlParameter['mode']!=undefined) |
432 mode=urlParameter['mode']; | |
433 if(mode==1){//locate the overlay selector on the map toolbar | |
434 $("#overlayIcon").hide(); | |
435 var overlayContainerObj=$("#overlayContainer"); | |
436 var overlayTitleObj=$("<td>Overlay</td>"); | |
437 overlayTitleObj.insertAfter("#mapContainer .absoluteToolbar tr:nth-child(1) td:nth-child(1)"); | |
438 var overlaySelectorObj=$("<td></td>"); | |
439 var overlayContainerPadding=5; | |
440 overlayContainerObj.css("padding",overlayContainerPadding+"px"); | |
441 //give the overlay selector the same look as the that of the background map and adjust the width | |
442 overlaySelectorObj.append("<div class='dropdownLeft'></div>"); | |
443 overlaySelectorObj.append("<div class='dropdownSelection'>select overlays</div>"); | |
444 overlaySelectorObj.append("<div class='dropdownButtonEnabled'></div>"); | |
445 overlaySelectorObj.insertAfter("#mapContainer .absoluteToolbar tr:nth-child(2) td:nth-child(1)"); | |
446 var w=parseInt(overlayContainerPadding*2+overlayContainerObj.width()); | |
447 overlaySelectorObj.width(w); | |
448 w=w-overlaySelectorObj.children(".dropdownLeft").width()-overlaySelectorObj.children(".dropdownButtonEnabled").width(); | |
449 overlaySelectorObj.children(".dropdownSelection").width(w); | |
450 overlaySelectorObj.append(overlayContainerObj); | |
451 //hide the overlay list and adjust the position | |
452 overlayContainerObj.hide(); | |
453 overlayContainerObj.css("position","absolute"); | |
454 var t=overlaySelectorObj.offset().top-parseInt(overlayContainerObj.css("padding"))+overlaySelectorObj.children(".dropdownButtonEnabled").height(); | |
455 //var l=overlaySelectorObj.offset().left-overlayContainerObj.width()/2; | |
456 var l=overlaySelectorObj.position().left-$("#rightWrapper").css("margin-left"); | |
457 overlayContainerObj.css("top",t); | |
458 overlayContainerObj.css("left",l); | |
459 overlayContainerObj.css("z-index",20000); | |
460 //toggle the visibility of the overlay list by clicking on the selector | |
461 overlaySelectorObj.click(function(){ | |
462 var visible=overlayContainerObj.is(":visible"); | |
463 if(visible){ | |
464 $(this).children(".selector").show(); | |
465 overlayContainerObj.hide(); | |
466 }else{ | |
467 $(this).children(".selector").hide(); | |
468 overlayContainerObj.show(); | |
469 } | |
470 }); | |
471 } | |
472 | |
473 $(".icon").each(function(){//adjust the position of the windows | |
474 var t=$(this).offset().top; | |
475 var l=$("#rightWrapper").css("margin-left"); | |
476 var windowName="."+$(this).attr("id"); | |
477 windowName=windowName.replace("Icon",""); | |
478 var windowObj=$(windowName); | |
479 windowObj.css("top",t); | |
480 windowObj.css("left",l); | |
481 }); | |
482 | |
483 // The following two sections are to hide/show the windows | |
484 $(".icon").click(function(){//toggle the visibility of the window by clicking on the icons | |
485 var windowName="."+$(this).attr("id"); | |
486 windowName=windowName.replace("Icon",""); | |
487 var windowObj=$(windowName); | |
488 if(windowObj.is(":visible")){ | |
489 //hide the window | |
490 windowObj.hide(); | |
491 $(this).removeClass("selected"); | |
492 }else{ | |
493 //show the window | |
494 if(windowObj.children(".windowWidgetBar").children(".visibilityButton").html()=="+"){ | |
495 windowObj.children(".windowWidgetBar").children(".visibilityButton").click(); | |
496 } | |
497 windowObj.show(); | |
498 $(this).addClass("selected"); | |
499 } | |
500 }); | |
501 $(".windowWidget .windowWidgetBar .visibilityButton").click(function(){ | |
502 if($(this).html()=="+"){//if the window is minimized, it should be hidden | |
503 $(this).parent().parent().hide(); | |
504 var windowName=$(this).parent().parent().attr("class"); | |
505 windowName=windowName.replace("container",""); | |
506 windowName=windowName.replace("windowWidget",""); | |
507 windowName=windowName.replace("ui-draggable",""); | |
508 windowName=windowName.replace(" ",""); | |
509 windowName=windowName.trim(); | |
510 windowName="#"+windowName+"Icon"; | |
511 $(windowName).removeClass("selected"); | |
512 } | |
513 }); | |
514 | |
515 } |