-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadgeo.js
82 lines (73 loc) · 1.79 KB
/
loadgeo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$.getScript("bd3.js",function(geojson3){
var features=eval(geojson3).features;
function getMap1(){
var map1={};
map1[0]=" ";
for (var i =0;i<features.length;i++) {
var name1=features[i].properties.NAME_1;
if (!(name1 in map1)){
map1[name1]=name1;
}
};
return map1;
}
function getMap2(value){
var map2={};
map2[0]=" ";
for(var j=0;j<features.length;j++){
var name2=features[j].properties.NAME_2;
var name1=features[j].properties.NAME_1;
if(name1==value && !(name2 in map2)){
map2[name2]=name2;
}
};
return map2;
}
function getMap3(value){
var map3={};
map3[0]=" ";
for(var j=0;j<features.length;j++){
var name3=features[j].properties.NAME_3;
var name2=features[j].properties.NAME_2;
if(name2==value && !(name3 in map3)){
map3[name3]=name3;
}
};
return map3;
}
function getMap3Features(value){
for(var j=0;j<features.length;j++){
var name3=features[j].properties.NAME_3;
if(name3==value ){
return features[j];
}
};
}
var options="";
$.each(getMap1(),function(i,t){
options += '<option value="' + t + '">' + t + '</option>';
});
$("#1").html(options);
$("#1").change(function () {
var selected = $(this).val();
var options="";
$.each(getMap2(selected),function(i,value){
options += '<option value="' + value + '">' + value + '</option>';
$("#2").html(options);
$("#3").html("");
});
});
$("#2").change(function () {
var selected = $(this).val();
var options="";
$.each(getMap3(selected),function(i,value,x){
options += '<option value="' + value + '">' + value + '</option>';
$("#3").html(options);
});
});
$("#3").change(function () {
var selected = $(this).val();
var map3Features=getMap3Features(selected);
alert(selected);
})
});