Mercurial > hg > LGMap
annotate map.js @ 16:bb63a70b8542
remove t floder
author | nylin@mpiwg-berlin.mpg.de |
---|---|
date | Tue, 10 Nov 2015 16:20:50 +0100 |
parents | f17f43f0a63f |
children | b4c4d04b8270 |
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: '世界地形圖', |
16 | 84 url: '../ts/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', |
16 | 86 attribution: "<a href='../ts/index.html?y=1982' target='_blank'>Data Source</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: '陳正祥–蝗神廟之分佈', |
16 | 102 url: '../ts/t/pa-cha/${z}/${x}/${y}.png', |
8
8f05c2a84bba
Apply new platin and Add tree layers
nylin@mpiwg-berlin.mpg.de
parents:
7
diff
changeset
|
103 type:'XYZ', |
16 | 104 attribution: "© 中國文化地理 陳正祥, <a href='../ts/index.html?y=1982' target='_blank'>Data Source</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']); |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
163 var obj={name:name,file:file,preload:true}; |
7
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(); |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
195 |
0 | 196 }); |
197 function getUrlParameter(){ | |
198 //examine the parameter "mode" in the url | |
199 var url=window.location.href; | |
200 var pos=url.indexOf("?"); | |
201 if(pos!=-1){ | |
202 var params=url.substring(pos+1); | |
203 var varArray=params.split("&"); | |
204 for(var i=0; i<varArray.length; i++){ | |
205 pos=varArray[i].indexOf("="); | |
206 var name=varArray[i].substring(0,pos); | |
207 var value=varArray[i].substring(pos+1); | |
208 urlParameter[name]=value; | |
209 /* | |
210 if(name=="mode"){ | |
211 mode=value; | |
212 }*/ | |
213 } | |
214 } | |
215 } | |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
216 |
0 | 217 function loadDataset(name,fileName){ |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
218 // zoe added |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
219 if (fileName==undefined) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
220 // 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
|
221 var fileId = urlParameter['fileId']; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
222 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
|
223 console.log("lgdv_url:"+lgdv_url); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
224 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
225 var fileData = {}; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
226 $.ajax({ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
227 url : lgdataverse_url+"getDatafile", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
228 async : false, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
229 type : 'GET', |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
230 data: 'fileId='+fileId, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
231 dataType: "json", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
232 success: function (data) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
233 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
|
234 fileData = data; |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
235 }, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
236 error: function (data) { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
237 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
|
238 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
|
239 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
240 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
241 }).done(function(result) { |
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 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
245 if (fileData.state == "ok") { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
246 /* |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
247 var json = [ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
248 { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
249 // these fields are required in map |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
250 "description":"20卷 ╱ (民國) 崔正春修 (民國) 尚希寳纂 ╱ 民國十八年鉛印本", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
251 "lat":36.974178, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
252 "lon":115.259262, |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
253 "place":"威縣", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
254 // ---- |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
255 "tableContent":{ |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
256 // 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
|
257 "description":"20卷 ╱ (民國) 崔正春修 (民國) 尚希寳纂 ╱ 民國十八年鉛印本", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
258 "name":"(民國) 威縣志", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
259 "place":"威縣", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
260 "testColumn1":"content1", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
261 "testColumn2":"content2", |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
262 "testColumn3":"content3", |
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 */ |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
268 |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
269 var dataCSVformat = fileData.file.dataString; |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
270 dataCSVformat = dataCSVformat.substring(0, dataCSVformat.length-2); // remove the last two characters which are "\n" |
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
271 // it will cause download error since the last element in table is null |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
272 //console.log(dataCSVformat); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
273 var json = GeoTemConfig.convertCsv(dataCSVformat); |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
274 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
|
275 |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
276 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
277 } else { |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
278 // zoe end |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
279 |
0 | 280 var csvFile=GeoTemConfig.getCsv(fileName, |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
281 function(json){ |
0 | 282 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
|
283 |
0 | 284 //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 |
285 $("#datasetContainer input:checkbox[value*='"+fileName+"']").prop("checked",true); | |
286 //rename the column "name" to "title" | |
287 $(".headerLabel").each(function(){ | |
288 if ($(this).html() == "name"){ | |
289 $(this).empty(); | |
290 $(this).html("title"); | |
291 } | |
292 }); | |
293 /*//this is redundant when calling GeoTemConfig.addDataset | |
294 //display in all widgets | |
295 map.display(GeoTemConfig.datasets); | |
296 timeline.display(GeoTemConfig.datasets); | |
297 table.display(GeoTemConfig.datasets); | |
298 pieChart.display(GeoTemConfig.datasets); */ | |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
299 |
0 | 300 } |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
301 |
0 | 302 ); |
15
f17f43f0a63f
bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
11
diff
changeset
|
303 |
7
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
304 } |
0330b2138c87
add collecting post data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
305 |
0 | 306 } |
307 function closeDataset(name,fileName){ | |
308 var idx; | |
309 //find the dataset to close by name | |
310 var data=$.grep(GeoTemConfig.datasets,function(val,key){ | |
311 if(val.label==name){ | |
312 idx=key; | |
313 } | |
314 return val.label==name; | |
315 }); | |
316 //GeoTemConfig.datasets.splice(idx,1); | |
317 GeoTemConfig.removeDataset(idx); | |
318 } | |
319 function initWidget(){ | |
320 var mapElem=document.getElementById("mapContainer"); | |
321 map=new WidgetWrapper(); | |
322 var mapWidget=new MapWidget(map,mapElem,{ | |
323 mapTitle:"", | |
10
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
324 minimumRadius:2, |
8f5635197895
new filter by columns and new layers
nylin@mpiwg-berlin.mpg.de
parents:
9
diff
changeset
|
325 baseLayer:'世界地形圖', //底圖 |
0 | 326 alternativeMap:backgroundMapArray |
327 }); | |
328 | |
329 var overlayLoaderElem=document.getElementById("overlayLoaderContainer"); | |
330 var overlayLoader=new WidgetWrapper(); | |
331 var overlayLoaderWidget=new OverlayloaderWidget(overlayLoader,overlayLoaderElem); | |
332 overlayLoaderWidget.attachMapWidget(mapWidget); | |
333 //insert overlay checkboxes | |
334 $.each(overlayArray,function(idx,obj){ | |
335 var name=obj.name; | |
336 var file=obj.file; | |
337 var preload=obj.preload; | |
338 var optionObj=$("<div class='option'></div>"); | |
339 $("#overlayContainer").append(optionObj); | |
340 var checkBoxObj=$("<input type='checkbox' name='"+name+"' value='"+file+"'>"); | |
341 checkBoxObj.prop("checked",preload); | |
342 optionObj.append(checkBoxObj); | |
343 var nameObj=$("<div class='label'>"+name+"</div>"); | |
344 optionObj.append(nameObj); | |
345 if(preload){ | |
346 overlayLoaderWidget.overlayLoader.distributeArcGISWMS(url,file); | |
347 } | |
348 }); | |
349 | |
350 $("#overlayContainer input:checkbox").click(function(e){ | |
351 //dirty insertion and deletion, delete all the overlays and insert them in the specified sequence | |
352 //in order to maintain the sequence of overlays, so that the smaller one will always be on top of the bigger ones | |
353 //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 | |
354 while($("#overlayLoaderContainer div:last-child a").length!=0){ | |
355 $("#overlayLoaderContainer div a:nth-child(1)").click(); | |
356 } | |
357 | |
358 $("#overlayContainer input:checkbox").each(function(){ | |
359 if($(this).is(":checked")){ | |
360 overlayLoaderWidget.overlayLoader.distributeArcGISWMS(url, | |
361 $(this).val()); | |
362 } | |
363 }); | |
364 //stop the event from propagating, or the list would close every time the user checks an item | |
365 e.stopPropagation(); | |
366 /* | |
367 //normal insertion and deletion | |
368 if($(this).is(":checked")){//selected | |
369 overlayLoaderWidget.overlayLoader.distributeArcGISWMS("http://geoserver.mpiwg-berlin.mpg.de/geoserver/China_Monograph_Project/ows", | |
370 $(this).val()); | |
371 }else{//deselect | |
372 var name=url+" - "+$(this).val(); | |
373 var layerNameArray=$("#overlayLoaderContainer > div:last-child").html().split('<a href="">(x)</a>'); | |
374 var idx=$.inArray(name,layerNameArray); | |
375 $("#overlayLoaderContainer div a:nth-child("+(idx+1)+")").click(); | |
376 }*/ | |
377 }); | |
378 | |
379 | |
380 //insert dataset checkboxes | |
381 $.each(datasetArray,function(idx,obj){ | |
382 var name=obj.name; | |
383 var file=obj.file; | |
384 var preload=obj.preload; | |
385 var optionObj=$("<div class='option'></div>"); | |
386 $("#datasetContainer ").append(optionObj); | |
387 var checkBoxObj=$("<input type='checkbox' name='"+name+"' value='"+file+"'>"); | |
388 optionObj.append(checkBoxObj); | |
389 //checkBoxObj.prop("checked",preload); | |
390 var nameObj=$("<div class='label'>"+name+"</div>"); | |
391 optionObj.append(nameObj); | |
392 if(preload){ | |
393 loadDataset(name,file); | |
394 } | |
395 }); | |
396 $("#datasetContainer input:checkbox").click(function(){ | |
397 /* | |
398 //dirty insertion and deletion, too slow | |
399 while($("#tableContainer .tableTabs").children().length!=0){ | |
400 //console.log($("#tableContainer .tableTabs").children().length); | |
401 //$("#tableContainer .tableTabs .tableTab:nth-child(1) .smallButton")[0].onclick(); | |
402 GeoTemConfig.removeDataset(0); | |
403 } | |
404 | |
405 $("#datasetContainer .content input:checkbox").each(function(){ | |
406 if($(this).is(":checked")){ | |
407 loadDataset($(this).attr("name"),$(this).val()); | |
408 } | |
409 }); | |
410 */ | |
411 if($(this).is(":checked")){//selected | |
412 loadDataset($(this).attr("name"),$(this).val()); | |
413 }else{ | |
414 closeDataset($(this).attr("name"),$(this).val()); | |
415 } | |
416 }); | |
417 var timelineElem=document.getElementById("timelineContainer"); | |
418 timeline=new WidgetWrapper(); | |
419 var timelineWidget=new FuzzyTimelineWidget(timeline,timelineElem,{ | |
420 timelineTitle:"" | |
421 }); | |
422 | |
423 var tableElem=document.getElementById("tableContainer"); | |
424 table=new WidgetWrapper(); | |
425 var tableWidget=new TableWidget(table,tableElem); | |
426 | |
427 var pieChartElem=document.getElementById("pieChartContainer"); | |
428 pieChart=new WidgetWrapper(); | |
429 var pieChartWidget=new PieChartWidget(pieChart,pieChartElem); | |
430 //pieChartWidget.addPieChart(0,"place"); | |
431 } | |
432 function initToolbar(){ | |
11 | 433 var mode=1; |
0 | 434 if(urlParameter['mode']!=undefined) |
435 mode=urlParameter['mode']; | |
436 if(mode==1){//locate the overlay selector on the map toolbar | |
437 $("#overlayIcon").hide(); | |
438 var overlayContainerObj=$("#overlayContainer"); | |
439 var overlayTitleObj=$("<td>Overlay</td>"); | |
440 overlayTitleObj.insertAfter("#mapContainer .absoluteToolbar tr:nth-child(1) td:nth-child(1)"); | |
441 var overlaySelectorObj=$("<td></td>"); | |
442 var overlayContainerPadding=5; | |
443 overlayContainerObj.css("padding",overlayContainerPadding+"px"); | |
444 //give the overlay selector the same look as the that of the background map and adjust the width | |
445 overlaySelectorObj.append("<div class='dropdownLeft'></div>"); | |
446 overlaySelectorObj.append("<div class='dropdownSelection'>select overlays</div>"); | |
447 overlaySelectorObj.append("<div class='dropdownButtonEnabled'></div>"); | |
448 overlaySelectorObj.insertAfter("#mapContainer .absoluteToolbar tr:nth-child(2) td:nth-child(1)"); | |
449 var w=parseInt(overlayContainerPadding*2+overlayContainerObj.width()); | |
450 overlaySelectorObj.width(w); | |
451 w=w-overlaySelectorObj.children(".dropdownLeft").width()-overlaySelectorObj.children(".dropdownButtonEnabled").width(); | |
452 overlaySelectorObj.children(".dropdownSelection").width(w); | |
453 overlaySelectorObj.append(overlayContainerObj); | |
454 //hide the overlay list and adjust the position | |
455 overlayContainerObj.hide(); | |
456 overlayContainerObj.css("position","absolute"); | |
457 var t=overlaySelectorObj.offset().top-parseInt(overlayContainerObj.css("padding"))+overlaySelectorObj.children(".dropdownButtonEnabled").height(); | |
458 //var l=overlaySelectorObj.offset().left-overlayContainerObj.width()/2; | |
459 var l=overlaySelectorObj.position().left-$("#rightWrapper").css("margin-left"); | |
460 overlayContainerObj.css("top",t); | |
461 overlayContainerObj.css("left",l); | |
462 overlayContainerObj.css("z-index",20000); | |
463 //toggle the visibility of the overlay list by clicking on the selector | |
464 overlaySelectorObj.click(function(){ | |
465 var visible=overlayContainerObj.is(":visible"); | |
466 if(visible){ | |
467 $(this).children(".selector").show(); | |
468 overlayContainerObj.hide(); | |
469 }else{ | |
470 $(this).children(".selector").hide(); | |
471 overlayContainerObj.show(); | |
472 } | |
473 }); | |
474 } | |
475 | |
476 $(".icon").each(function(){//adjust the position of the windows | |
477 var t=$(this).offset().top; | |
478 var l=$("#rightWrapper").css("margin-left"); | |
479 var windowName="."+$(this).attr("id"); | |
480 windowName=windowName.replace("Icon",""); | |
481 var windowObj=$(windowName); | |
482 windowObj.css("top",t); | |
483 windowObj.css("left",l); | |
484 }); | |
485 | |
486 // The following two sections are to hide/show the windows | |
487 $(".icon").click(function(){//toggle the visibility of the window by clicking on the icons | |
488 var windowName="."+$(this).attr("id"); | |
489 windowName=windowName.replace("Icon",""); | |
490 var windowObj=$(windowName); | |
491 if(windowObj.is(":visible")){ | |
492 //hide the window | |
493 windowObj.hide(); | |
494 $(this).removeClass("selected"); | |
495 }else{ | |
496 //show the window | |
497 if(windowObj.children(".windowWidgetBar").children(".visibilityButton").html()=="+"){ | |
498 windowObj.children(".windowWidgetBar").children(".visibilityButton").click(); | |
499 } | |
500 windowObj.show(); | |
501 $(this).addClass("selected"); | |
502 } | |
503 }); | |
504 $(".windowWidget .windowWidgetBar .visibilityButton").click(function(){ | |
505 if($(this).html()=="+"){//if the window is minimized, it should be hidden | |
506 $(this).parent().parent().hide(); | |
507 var windowName=$(this).parent().parent().attr("class"); | |
508 windowName=windowName.replace("container",""); | |
509 windowName=windowName.replace("windowWidget",""); | |
510 windowName=windowName.replace("ui-draggable",""); | |
511 windowName=windowName.replace(" ",""); | |
512 windowName=windowName.trim(); | |
513 windowName="#"+windowName+"Icon"; | |
514 $(windowName).removeClass("selected"); | |
515 } | |
516 }); | |
517 | |
518 } |