-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeoJson.pde
139 lines (113 loc) · 3.39 KB
/
GeoJson.pde
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.marker.AbstractMarker;
import java.util.List;
UnfoldingMap map_1;
UnfoldingMap map_2;
UnfoldingMap map_3;
HashMap<String, DataEntry> dataEntriesMap;
List<Marker> chinaMarkers;
List<Marker> provinceMarkers;
List<Marker> chinacpMarkers;
List<Feature> province;
Location yinchuanLocation=new Location(38.467,106.267);
Location location;
HScrollbar hs; //scrollbar
Button bt;
String text_1 = "per to region";
String text_2 = "region to per";
String id = "33";
String newid="42";
ArrayList<cityPoint> citypoint=new ArrayList<cityPoint>();
MarkerManager manager = new MarkerManager();
MarkerManager manager3 = new MarkerManager();
ArrayList<provinceLine> provinceline=new ArrayList<provinceLine>();
String[] perid;//for find data's province
void setup() {
size(1200, 700, P2D);
smooth();
hs = new HScrollbar(150, height*11/12, 500, 16);
bt = new Button(340,height*5/6,120,24,text_1);
map_1 = new UnfoldingMap(this,10,10,800,550);
map_1.zoomAndPanTo(yinchuanLocation, 4);
MapUtils.createDefaultEventDispatcher(this, map_1);
// Load province polygons and adds them as markers
List<Feature> china = GeoJSONReader.loadData(this, "chinaCapital.json");
chinaMarkers = MapUtils.createSimpleMarkers(china);
map_1.addMarkers(chinaMarkers);
map_1.setTweening(true);
//map.setPanningRestriction(yinchuanLocation, 200 );
//map.resetPanningRestriction();
readcitycsv();
drawcity();
map_2 = new UnfoldingMap(this,820,15,370,330);
map_2.setTweening(true);
map_3 = new UnfoldingMap(this,820,345,370,330);
map_3.zoomAndPanTo(yinchuanLocation, 3);
MapUtils.createDefaultEventDispatcher(this, map_3);
List<Feature> chinacp = GeoJSONReader.loadData(this, "china.json");
chinacpMarkers = MapUtils.createSimpleMarkers(chinacp);
map_3.addMarkers(chinacpMarkers);
map_3.addMarkerManager(manager3);
map_3.setTweening(true);
resetMap(chinacpMarkers,color(255,255,255));
readpopulation();
}
void draw() {
background(240);
hs.update();
hs.display();
map_1.draw();
pointColorUpdate();
//bt.mouseClicked();
bt.display();
bt.Stringdisplay();
chinaMapUpdate();
mouseMoved();
//provinceDraw();
map_2.draw();
//provinceMapUpdate();
map_3.draw();
}
void mouseClicked() {
if (bt.overRect()) {
if(bt.text == text_1)
bt.text = text_2;
else if (bt.text == text_2)
bt.text = text_1;
}
Marker marker = map_1.getFirstHitMarker(mouseX, mouseY);
if (marker != null)
id = marker.getId();
if(id != null){
provinceUpdate();
}
provinceMapUpdate();
}
void mouseMoved() {
// Deselect all marker
/*
for (Marker marker : map_1.getMarkers()) {
marker.setSelected(false);}
*/
// Select hit marker
// Note: Use getHitMarkers(x, y) if you want to allow multiple selection.
Marker marker = map_1.getFirstHitMarker(mouseX, mouseY);
if (marker != null) {
//marker.setSelected(true);
marker.setColor(color(0,255,255));
}
Marker marker2 = map_3.getFirstHitMarker(mouseX, mouseY);
{
if (marker2 != null) {
newid = marker2.getId();
if(newid != null)
manager3.clearMarkers();
drawproline();
}
}
}