-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirectFrag.java
355 lines (257 loc) · 10.2 KB
/
DirectFrag.java
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
package com.example.elvin.projectapp1;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
public class DirectFrag extends FragmentActivity implements OnMapReadyCallback,
GoogleMap.OnMarkerClickListener{
public static GoogleMap mMap;
public double latitude = 35.135525;
public double longitude = -78.871735;
public boolean routeInfo = false;
public static Marker Rid;
public static Marker Hen;
public static Marker Bern;
public static Marker Tee;
public static Marker Alli;
public static Marker Nim;
public static Marker MyLoc;
public static Marker Nurse;
public static Marker NorthD;
public static Marker CVOD;
public static Marker SandD;
public static Marker WeaveD;
public static Marker GarberD;
public static Marker StadiumM;
public static Marker ClarkM;
public Polyline route;
public static filterMap fm;
public static boolean showHendricks = true;
public static boolean showRiddle = true;
public static boolean showNimmocks = true;
public static boolean showAllison = true;
public static boolean showBerns = true;
public static boolean showTrusted = true;
public static boolean showCVO = true;
public static boolean showSand = true;
public static boolean showGarber= true;
public static boolean showWeave = true;
public static boolean showNorth= true;
public static boolean showStadium = true;
public static boolean showNurse = true;
public static boolean showClark = true;
public static CheckBox chkF1 ;
public static CheckBox chkF2 ;
public static CheckBox chkF3 ;
public static CheckBox chkF4 ;
public LatLngBounds Methodist = new LatLngBounds(
new LatLng(35.131662, -78.877319), new LatLng(35.136628,-78.869573));
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.directfraglayout);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
fm = new filterMap(DirectFrag.this);
chkF1 = (CheckBox)findViewById(R.id.chkFilter1);
chkF2 = (CheckBox)findViewById(R.id.chkFilter2);
chkF3 = (CheckBox)findViewById(R.id.chkFilter3);
chkF4 = (CheckBox)findViewById(R.id.chkFilter4);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setMinZoomPreference(17.0f);
mMap.setMaxZoomPreference(18.0f);
// Add a marker in Sydney and move the camera
//LatLng mu = new LatLng(35.133462, -78.872675);
LatLng you = new LatLng(latitude, longitude);
LatLng Nimmocks = new LatLng(35.135964, -78.870780);
LatLng Riddle = new LatLng(35.134069, -78.870512);
LatLng Hendricks = new LatLng(35.135525, -78.871735);
LatLng Allison = new LatLng(35.135753, -78.872797);
LatLng Trusted = new LatLng(35.134481, -78.873934);
LatLng Berns = new LatLng(35.134367, -78.872121);
LatLng NurseL = new LatLng(35.133408, -78.873375);
LatLng North = new LatLng(35.137842, -78.872615);
LatLng CVO = new LatLng(35.134539, -78.868943);
LatLng Weave = new LatLng(35.136444, -78.869608);
LatLng Sand = new LatLng(35.135513, -78.868696);
LatLng Garber = new LatLng(35.135774, -78.869914);
LatLng Stadium = new LatLng(35.133176,-78.871708);
LatLng Clark = new LatLng(35.133443,-78.874210);
MyLoc = mMap.addMarker(new MarkerOptions().position(you).title("Your Current Location").
icon(BitmapDescriptorFactory.fromResource(R.drawable.star)));
MyLoc.setTag(1);
Rid = mMap.addMarker(new MarkerOptions().position(Riddle).title("Riddle Athletic Center"));
Nim = mMap.addMarker(new MarkerOptions().position(Nimmocks).title("Nimmocks Fitness Center"));
Hen = mMap.addMarker(new MarkerOptions().position(Hendricks).title("Hendricks Science Complex"));
Alli = mMap.addMarker(new MarkerOptions().position(Allison).title("Allison Computer Science and Math Hall"));
Tee = mMap.addMarker(new MarkerOptions().position(Trusted).title("Trustees Building"));
Bern = mMap.addMarker(new MarkerOptions().position(Berns).title("Berns Student Center"));
Nurse = mMap.addMarker(new MarkerOptions().position(NurseL).title("Nursing Building"));
CVOD = mMap.addMarker(new MarkerOptions().position(CVO).title("Cumberland Hall"));
GarberD = mMap.addMarker(new MarkerOptions().position(Garber).title("Garber Hall"));
NorthD = mMap.addMarker(new MarkerOptions().position(North).title("North Hall"));
WeaveD = mMap.addMarker(new MarkerOptions().position(Weave).title("Weaver Hall"));
SandD = mMap.addMarker(new MarkerOptions().position(Sand).title("Sanford Hall"));
StadiumM = mMap.addMarker(new MarkerOptions().position(Stadium).title("Monarch Stadium"));
ClarkM = mMap.addMarker(new MarkerOptions().position(Clark).title("Clark Hall"));
if (showRiddle == true){
Rid.setTag(2);
}
else{
Rid.remove();
}
if (showNimmocks == true){
Nim.setTag(3);
}
else{
Nim.remove();
}
if (showHendricks == true){
Hen.setTag(4);
}
else{
Hen.remove();
}
if (showAllison== true){
Alli.setTag(5);
}
else{
Alli.remove();
}
if (showTrusted == true){
Tee.setTag(6);
}
else{
Tee.remove();
}
if (showBerns == true){
Bern.setTag(7);
}
else{
Bern.remove();
}
if (showNorth == true){
}
else{
NorthD.remove();
}
if (showCVO == true){
}
else{
CVOD.remove();
}
if (showSand == true){
}
else{
SandD.remove();
}
if (showWeave == true){
}
else{
WeaveD.remove();
}
if (showGarber == true){
}
else{
GarberD.remove();
}
if(showStadium == true){
}
else{
StadiumM.remove();
}
if(showNurse == true){
}
else{
Nurse.remove();
}
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(you,17));
mMap.setLatLngBoundsForCameraTarget(Methodist);
mMap.setOnMarkerClickListener(this);
}
@Override
public boolean onMarkerClick(final Marker marker) {
if(route != null){
route.remove();
}
if (marker.equals(StadiumM))
{
StadiumM.showInfoWindow();
route = mMap.addPolyline(new PolylineOptions()
.add(
new LatLng(latitude, longitude),
new LatLng(35.135301,-78.871891),
new LatLng(35.135237,-78.871530),
new LatLng(35.134091,-78.872038),
new LatLng(35.133176,-78.871708)
)
);
}
else if (marker.equals(Alli)){
Alli.showInfoWindow();
if(routeInfo == true){
customDialog cd = new customDialog(DirectFrag.this);
cd.show();
}
else {
routeInfo = true;
}
route = mMap.addPolyline(new PolylineOptions()
.add(
new LatLng(latitude, longitude),
new LatLng(35.135753,-78.872797))
);
}
else if (marker.equals(Bern)){
}
else if(marker.equals(Nim)){
}
else if(marker.equals(Tee)){
}
else if (marker.equals(ClarkM)){
ClarkM.showInfoWindow();
if(routeInfo == true){
customDialog cd = new customDialog(DirectFrag.this);
cd.show();
}
else {
routeInfo = true;
}
route = mMap.addPolyline(new PolylineOptions()
.add(
new LatLng(latitude, longitude),
new LatLng(35.135300,-78.871891),
new LatLng(35.135058,-78.872467),
new LatLng(35.134620,-78.872662),
new LatLng(35.134677,-78.872894),
new LatLng(35.134324,-78.873045),
new LatLng(35.134369,-78.873214),
new LatLng(35.133868,-78.873427),
new LatLng(35.133942,-78.873668),
new LatLng(35.133700,-78.873793),
new LatLng(35.133791,-78.874098),
new LatLng(35.133443,-78.874210)
)
);
}
return true;
}
public void filterMapShow (View view) {
fm.show();
}
}