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