-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.html
911 lines (739 loc) · 33.2 KB
/
Map.html
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
<html>
<head>
<title>Remapping King Philip's War: Map</title>
<!-- Import Leaflet-provided CSS stylesheet and JS library -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
<!-- CSS style specifically for map legend -->
<style>
/*Legend specific*/
.legend {
padding: 6px 8px;
font: 14px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255, 255, 255, 0.8);
/*box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);*/
/*border-radius: 5px;*/
line-height: 24px;
color: #555;
}
.legend h4 {
text-align: center;
font-size: 16px;
margin: 2px 12px 8px;
color: #777;
}
.legend span {
position: relative;
bottom: 3px;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin: 0 8px 0 0;
opacity: 0.7;
}
.legend i.icon {
background-size: 18px;
background-color: rgba(255, 255, 255, 1);
}
</style>
<!--General CSS for whole page: body and headers-->
<style>
body {
font-family: 'Trebuchet MS', sans-serif;
margin: 50;
margin-top:10;
background-color: white;
background-image: linear-gradient(rgb(52, 158, 52), white)
}
h1{
color:darkblue
}
h2{
color:darkblue
}
h3{
color:saddlebrown
}
h4{
color:saddlebrown
}
</style>
</head>
<body>
<p><a href="index.html">Back to home page</a></p>
<!-- HTML div for primary map window, ADJUST MAP SIZE HERE -->
<div id="mapid" style="width: 1200px; height: 700px;"></div>
<!-- HTML div for "time control" buttons underneath the map. These buttons call dedicated JS functions -->
<div id="buttons" style="width:1200px; text-align:center">
Select a time period to view locations: <br>
<button type="button" style="display:inline-block; font-size:16px;" onclick="prewar()">Pre-War (before August 1675)</button>
<button type="button" style="display:inline-block; font-size:16px;" onclick="wartime()">Wartime (About August 1675-April 1678)</button>
<button type="button" style="display:inline-block; font-size:16px;" onclick="postwar()">Post-War (after April 1678)</button>
</div>
<p>
<a href="bib.html">Mapping Sources/Bibliography</a>
</p>
<!-- Required Creative Commons license information for a couple of icons used on the map -->
<p style="font-size:12">
Praying Indian town icon, composite of "<a href="https://commons.wikimedia.org/wiki/File:Eliot_Church_and_John_Eliot_plaque_in_South_Natick_MA_USA_Site_of_First_Indian_meetinghouse_built_by_John_Eliot_and_Natick_Indians_His_disciple_Daniel_Takawambait_succeeded_to_the_pastoral_office_in_1698.jpg">Eliot Church and John Eliot plaque in South Natick MA USA Site of First Indian meetinghouse built by John Eliot and Natick Indians His disciple Daniel Takawambait succeeded to the pastoral office in 1698</a>" and "<a href="https://commons.wikimedia.org/wiki/File:Eliot_Church_Unitarian_Universalist_in_South_Natick_MA_USA.jpg">Eliot Church Unitarian Universalist in South Natick MA USA</a>," photographs taken by Swampyank on Oct 25, 2020, photographs adapted by Cameron Fiddes on April 12, 2021 under the terms of <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC-BY-SA-4.0</a>. Swampyank is not affilitated with this project or any of its members.
</p>
<p style="font-size:12">
Indian village icon, "<a href="https://flic.kr/p/piXqkf">this communal wetu would shelter 3 families</a>," photograph taken by Nicolás Boullosa on August 16, 2014, photograph adapted by Cameron Fiddes on April 4, 2021 under the terms of <a href="https://creativecommons.org/licenses/by/2.0/">CC-BY-2.0</a>. Nicolás Boullosa is not affiliated with this project or any of its members.
</p>
<!-- BEGIN JS SCRIPTS HERE -->
<!-- Import GeoJSON here. NOTE: These files have .js scripts that declare each JSON object as a variable ready to use -->
<script src="ColonistTownsGeoJSON.js" type="text/javascript"></script>
<script src="PrayingTownsGeoJSON.js" type="text/javascript"></script>
<script src="IndianVillagesGeoJSON.js" type="text/javascript"></script>
<!-- General script for establishing full Leaflet Map -->
<script>
//establish variables for different tile base layers
var SAT = L.tileLayer('https://api.mapbox.com/styles/v1/jmckeen/cklr9kiqp0acf17ql1krryp9a/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1Ijoiam1ja2VlbiIsImEiOiJja2htOG5hOGYwa3V5Mndua2wxNmk0b3IwIn0.mrxqcVZ9RgN7TMVLIOvOzg', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
tileSize: 512,
zoomOffset: -1,
});
var MAP = L.tileLayer('https://api.mapbox.com/styles/v1/jmckeen/cklt2i71o21a117mrqyjlzw2g/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1Ijoiam1ja2VlbiIsImEiOiJja2htOG5hOGYwa3V5Mndua2wxNmk0b3IwIn0.mrxqcVZ9RgN7TMVLIOvOzg', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
tileSize: 512,
zoomOffset: -1,
});
var OLD = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/satellite-streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoiam1ja2VlbiIsImEiOiJja2htOG5hOGYwa3V5Mndua2wxNmk0b3IwIn0.mrxqcVZ9RgN7TMVLIOvOzg'
});
//ESTABLISHING MARKER COLORS USING leaflet-color-markers library
//Additional custom markers used, located in /icons folder
//set dedicated Height for the Wetu icons, as this icon has dimensions that are much more "square" compared to the others
var wetuIconHeight = 25;
var greenIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var greenWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-icongreen.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, wetuIconHeight],
iconAnchor: [12, wetuIconHeight],
popupAnchor: [1, -34],
shadowSize: [41, wetuIconHeight]
});
var goldIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-gold.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var goldWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-iconyellow.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, wetuIconHeight],
iconAnchor: [12, wetuIconHeight],
popupAnchor: [1, -34],
shadowSize: [41, wetuIconHeight]
});
var redIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var redColTown = new L.Icon({
iconUrl: 'icons/colonist/colonistmeetinghouse-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var redBattle = new L.Icon({
iconUrl: 'icons/violence/violenceicon-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var violetIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-violet.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var violetWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-iconpurple.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var violetShackles = new L.Icon({
iconUrl: 'icons/shackles/shackle-iconpurple.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 30],
iconAnchor: [12, 30],
popupAnchor: [1, -34],
shadowSize: [41, 30]
});
var yellowIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-yellow.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var yellowWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-icondarkyellow.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, wetuIconHeight],
iconAnchor: [12, wetuIconHeight],
popupAnchor: [1, -34],
shadowSize: [41, wetuIconHeight]
});
var yellowViolence = new L.Icon({
iconUrl: 'icons/violence/violenceicon-darkyellow.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var orangeIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-orange.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var orangeWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-iconorange.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, wetuIconHeight],
iconAnchor: [12, wetuIconHeight],
popupAnchor: [1, -34],
shadowSize: [41, wetuIconHeight]
});
var orangeCorn = new L.Icon({
iconUrl: 'icons/corn/cornicon-orange.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var orangeViolence = new L.Icon({
iconUrl: 'icons/violence/violenceicon-orange.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var blueWetu = new L.Icon({
iconUrl: 'icons/wetu/wetu-iconblue.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, wetuIconHeight],
iconAnchor: [12, wetuIconHeight],
popupAnchor: [1, -34],
shadowSize: [41, wetuIconHeight]
});
var blueCorn = new L.Icon({
iconUrl: 'icons/corn/cornicon-blue.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var blueChurch = new L.Icon({
iconUrl: 'icons/eliot/eliot-church-icon-final-blue.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var greenChurch = new L.Icon({
iconUrl: 'icons/eliot/eliot-church-icon-final-green.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
//These functions are called on every GeoJSON feature imported from the ColonistTownsGeoJSON file
function onEachPreColonistTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.prewar) { //filter here for features that have a "prewar" properties value
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.prewar;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker){ //set red colonist town marker
layer.setIcon(redColTown);
}
if (layer instanceof L.Path && feature.properties.prewar){ //set red polygon
layer.setStyle({fillColor:'red', color:'red'});
}
}
function onEachWarColonistTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.wartime) { //filter for "wartime"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.wartime;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker){
layer.setIcon(redBattle); //red battle icon
}
if (layer instanceof L.Path){
layer.setStyle({fillColor:'red', color:'red'}); //red outline for polygons
}
}
function onEachPostColonistTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.postwar) { //filter for "postwar"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.postwar;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker){ //red colonist town icon
layer.setIcon(redColTown);
}
if (layer instanceof L.Path){
layer.setStyle({fillColor:'red', color:'red'}); //red polygons
}
}
//These functions are called on every GeoJSON feature imported from the PrayingTownsGeoJSON file
function onEachPrePrayingTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.prewar) { //filter for "prewar"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.prewar;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker && feature.properties.type=="old"){ //icon for old praying towns
layer.setIcon(blueChurch);
}
if (layer instanceof L.Marker && feature.properties.type=="old" && feature.properties.planting=="true"){ //icon for old praying towns' planting areas
layer.setIcon(blueCorn);
}
if (layer instanceof L.Marker && feature.properties.type=="new"){ //new praying towns
layer.setIcon(greenChurch);
}
if (layer instanceof L.Path && feature.properties.type=="new"){ //new praying town polygons
layer.setStyle({fillColor:'green', color:'green'});
}
if (layer instanceof L.Marker && feature.properties.type=="internment"){ //internment locations
layer.setIcon(violetIcon);
}
if (layer instanceof L.Path && feature.properties.type=="internment"){ //interment location polygons
layer.setStyle({fillColor:'violet', color:'violet'});
}
}
function onEachWarPrayingTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.wartime) { //filter for "wartime"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.wartime;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker && feature.properties.type=="old"){ //old praying town icon
layer.setIcon(blueChurch);
}
if (layer instanceof L.Marker && feature.properties.type=="new"){ //new praying town icon
layer.setIcon(greenChurch);
}
if (layer instanceof L.Path && feature.properties.type=="new"){ //new praying town polygon
layer.setStyle({fillColor:'green', color:'green'});
}
if (layer instanceof L.Marker && feature.properties.type=="internment"){ //wartime internment icon
layer.setIcon(violetShackles);
}
if (layer instanceof L.Path && feature.properties.type=="internment"){ //wartime internment polygon
layer.setStyle({fillColor:'violet', color:'violet'});
}
}
function onEachPostPrayingTown(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.postwar) { //filter for "postwar"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.postwar;
}
layer.bindPopup(popupContent);
if (layer instanceof L.Marker && feature.properties.type=="old"){ //postwar old praying town icon
layer.setIcon(blueChurch);
}
if (layer instanceof L.Marker && feature.properties.type=="new"){ //new praying town icon
layer.setIcon(greenChurch);
}
if (layer instanceof L.Path && feature.properties.type=="new"){ //new praying town polygon
layer.setStyle({fillColor:'green', color:'green'});
}
if (layer instanceof L.Marker && feature.properties.type=="internment"){ //postwar interment icon
layer.setIcon(violetShackles);
}
if (layer instanceof L.Path && feature.properties.type=="internment"){ //postwar internment polygon
layer.setStyle({fillColor:'violet', color:'violet'});
}
}
//these functions are called on every GeoJSON feature imported from the IndianVillagesGeoJSON file
function onEachPreIndianVillage(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.prewar) { //filter for prewar
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.prewar;
}
layer.bindPopup(popupContent);
//icon and polygon color for each tribe
if (layer instanceof L.Marker && feature.properties.type=="Nipmuc"){
layer.setIcon(goldWetu);
}
if (layer instanceof L.Path && feature.properties.type=="Nipmuc"){
layer.setStyle({fillColor:'gold', color:'gold'});
}
if (layer instanceof L.Marker && feature.properties.type=="Narragansett"){
layer.setIcon(yellowWetu);
}
if (layer instanceof L.Path && feature.properties.type=="Narragansett"){
layer.setStyle({fillColor:'yellow', color:'yellow'});
}
if (layer instanceof L.Marker && feature.properties.type=="Wampanoag"){
layer.setIcon(orangeWetu);
}
if (layer instanceof L.Marker && feature.properties.type=="Wampanoag" && feature.properties.planting=="true"){ //specifically check for Wampanoag planting area
layer.setIcon(orangeCorn);
}
if (layer instanceof L.Path && feature.properties.type=="Wampanoag"){
layer.setStyle({fillColor:'orange', color:'orange'});
}
}
function onEachWarIndianVillage(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.wartime) { //filter for "wartime"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.wartime;
}
layer.bindPopup(popupContent);
//icon and polygon color for each tribe
if (layer instanceof L.Marker && feature.properties.type=="Nipmuc"){
layer.setIcon(goldWetu);
}
if (layer instanceof L.Path && feature.properties.type=="Nipmuc"){
layer.setStyle({fillColor:'gold', color:'gold'});
}
if (layer instanceof L.Marker && feature.properties.type=="Narragansett"){
layer.setIcon(yellowWetu);
}
if (layer instanceof L.Marker && feature.properties.type=="Narragansett" && feature.properties.battle=="true"){ //check for Narragansett battle location
layer.setIcon(yellowViolence);
}
if (layer instanceof L.Path && feature.properties.type=="Narragansett"){
layer.setStyle({fillColor:'yellow', color:'yellow'});
}
if (layer instanceof L.Marker && feature.properties.type=="Wampanoag"){
layer.setIcon(orangeIcon);
}
if (layer instanceof L.Marker && feature.properties.type=="Wampanoag" && feature.properties.battle=="true"){ //check for Wampanoag battle location
layer.setIcon(orangeViolence);
}
if (layer instanceof L.Path && feature.properties.type=="Wampanoag"){
layer.setStyle({fillColor:'orange', color:'orange'});
}
}
function onEachPostIndianVillage(feature, layer) {
var popupContent = "";
if (feature.properties && feature.properties.name && feature.properties.postwar) { //check for "postwar"
popupContent += ("<b>" + feature.properties.name + "</b>" + "<br><br>");
popupContent += feature.properties.postwar;
}
layer.bindPopup(popupContent);
//icon color and polygon color for each tribe
if (layer instanceof L.Marker && feature.properties.type=="Nipmuc"){
layer.setIcon(goldIcon);
}
if (layer instanceof L.Path && feature.properties.type=="Nipmuc"){
layer.setStyle({fillColor:'gold', color:'gold'});
}
if (layer instanceof L.Marker && feature.properties.type=="Narragansett"){
layer.setIcon(yellowIcon);
}
if (layer instanceof L.Path && feature.properties.type=="Narragansett"){
layer.setStyle({fillColor:'yellow', color:'yellow'});
}
if (layer instanceof L.Marker && feature.properties.type=="Wampanoag"){
layer.setIcon(orangeIcon);
}
if (layer instanceof L.Path && feature.properties.type=="Wampanoag"){
layer.setStyle({fillColor:'orange', color:'orange'});
}
}
//STRUCTURE: var LAYERNAME = L.GeoJSON(geoJSONVariableNameInJsFile, {onEachFeature: onEachFeatureFunctionName,
// filter: function(feature, layer) {return PROPERTY TO CHECK NONEMPTY != "";}});
// essentially, this filter checks to see if the property prewar, wartime, or postwar strings are not empty, and if so allows the feature through the filter
//Importing Colonist Towns from GeoJSON and run onEachFeatureFunction for each feature
var PRECOLTOWNS = L.geoJSON(colonistTowns, {
onEachFeature: onEachPreColonistTown,
filter: function(feature, layer){
return feature.properties.prewar != "";
}
});
var WARCOLTOWNS = L.geoJSON(colonistTowns, {
onEachFeature: onEachWarColonistTown,
filter: function(feature, layer){
return feature.properties.wartime != "";
}
});
var POSTCOLTOWNS = L.geoJSON(colonistTowns, {
onEachFeature: onEachPostColonistTown,
filter: function(feature, layer){
return feature.properties.postwar != "";
}
});
//Importing Old Praying Towns from GeoJSON and run onEachFeatureFunction for each feature
var PREOLDPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachPrePrayingTown,
filter: function(feature, layer){
return (feature.properties.prewar != "" && feature.properties.type == "old");
}
});
var WAROLDPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachWarPrayingTown,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "old");
}
});
var POSTOLDPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachPostPrayingTown,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "old");
}
});
//Importing New Praying Towns from GeoJSON and run onEachFeatureFunction for each feature
var PRENEWPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachPrePrayingTown,
filter: function(feature, layer){
return (feature.properties.prewar != "" && feature.properties.type == "new");
}
});
var WARNEWPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachWarPrayingTown,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "new");
}
});
var POSTNEWPRAYTOWNS = L.geoJSON(prayingTowns, {
onEachFeature: onEachPostPrayingTown,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "new");
}
});
//Importing Internment Towns from GeoJSON and run onEachFeatureFunction for each feature
var WARINTERNMENT = L.geoJSON(prayingTowns, {
onEachFeature: onEachWarPrayingTown,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "internment");
}
});
var POSTINTERNMENT = L.geoJSON(prayingTowns, {
onEachFeature: onEachPostPrayingTown,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "internment");
}
});
//Importing Nipmuc Villages from GeoJSON and run onEachFeatureFunction for each feature
var PRENIPMUCVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPreIndianVillage,
filter: function(feature, layer){
return (feature.properties.prewar != "" && feature.properties.type == "Nipmuc");
}
});
var WARNIPMUCVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachWarIndianVillage,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "Nipmuc");
}
});
var POSTNIPMUCVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPostIndianVillage,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "Nipmuc");
}
});
//Importing Wampanoag Villages from GeoJSON and run onEachFeatureFunction for each feature
var PREWAMPANOAGVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPreIndianVillage,
filter: function(feature, layer){
return (feature.properties.prewar != "" && feature.properties.type == "Wampanoag");
}
});
var WARWAMPANOAGVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachWarIndianVillage,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "Wampanoag");
}
});
var POSTWAMPANOAGVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPostIndianVillage,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "Wampanoag");
}
});
//Importing Narragansett Villages from GeoJSON and run onEachFeatureFunction for each feature
var PRENARRAGANSETTVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPreIndianVillage,
filter: function(feature, layer){
return (feature.properties.prewar != "" && feature.properties.type == "Narragansett");
}
});
var WARNARRAGANSETTVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachWarIndianVillage,
filter: function(feature, layer){
return (feature.properties.wartime != "" && feature.properties.type == "Narragansett");
}
});
var POSTNARRAGANSETTVILLAGES = L.geoJSON(indianVillages, {
onEachFeature: onEachPostIndianVillage,
filter: function(feature, layer){
return (feature.properties.postwar != "" && feature.properties.type == "Narragansett");
}
});
//create map with center set, zoom set, and layers list
//under "layers", this is where we define which layers are shown on the map on first load. These may be changed by the user with the layer controls
//"layers" includes both the baselayer and any data layers
var mymap = L.map('mapid', {
center: [42.445, -71.68],
zoom: 8,
layers: [MAP, PRECOLTOWNS, PREOLDPRAYTOWNS, PRENEWPRAYTOWNS, PRENIPMUCVILLAGES, PREWAMPANOAGVILLAGES, PRENARRAGANSETTVILLAGES]
});
//ADDING LAYER CONTROLS:
//baseLayers group (mutually exclusive, one at a time):
var baseMaps = {
"Topographical": MAP,
"Satellite": SAT,
"Sat. Modern Labels": OLD
};
//Layer groups defined here for each time period, so the time period "switcher" functions can easily enable/disable them
var preLayerGroup = L.layerGroup([PRECOLTOWNS, PREOLDPRAYTOWNS, PRENEWPRAYTOWNS, PRENIPMUCVILLAGES, PREWAMPANOAGVILLAGES, PRENARRAGANSETTVILLAGES]);
var warLayerGroup = L.layerGroup([WARCOLTOWNS, WAROLDPRAYTOWNS, WARNEWPRAYTOWNS, WARINTERNMENT, WARNIPMUCVILLAGES, WARWAMPANOAGVILLAGES, WARNARRAGANSETTVILLAGES]);
var postLayerGroup = L.layerGroup([POSTCOLTOWNS, POSTOLDPRAYTOWNS, POSTNEWPRAYTOWNS, POSTINTERNMENT, POSTNIPMUCVILLAGES, POSTWAMPANOAGVILLAGES, POSTNARRAGANSETTVILLAGES]);
//information (geographic points/areas) overlays to be placed on top of the baselayers
//three separate groups defined here so the options can change depending on the time period
//note: these only set the layers switching controls visible to the user, not the actual layers that switch in the time periods
var preOverlayMaps = {
"Colonist Towns": PRECOLTOWNS,
"Praying Towns (Old)": PREOLDPRAYTOWNS,
"Praying Towns (New)": PRENEWPRAYTOWNS,
"Nipmuc Villages": PRENIPMUCVILLAGES,
"Wampanoag Villages": PREWAMPANOAGVILLAGES,
"Narragansett Villages": PRENARRAGANSETTVILLAGES
};
var warOverlayMaps = {
"Colonist Towns": WARCOLTOWNS,
"Praying Towns (Old)": WAROLDPRAYTOWNS,
"Praying Towns (New)": WARNEWPRAYTOWNS,
"Internment Location": WARINTERNMENT,
"Nipmuc Villages": WARNIPMUCVILLAGES,
"Wampanoag Villages": WARWAMPANOAGVILLAGES,
"Narragansett Villages": WARNARRAGANSETTVILLAGES
};
var postOverlayMaps = {
"Colonist Towns": POSTCOLTOWNS,
"Praying Towns (Old)": POSTOLDPRAYTOWNS,
"Praying Towns (New)": POSTNEWPRAYTOWNS,
"Slavery Location": POSTINTERNMENT,
"Nipmuc Villages": POSTNIPMUCVILLAGES,
"Wampanoag Villages": POSTWAMPANOAGVILLAGES,
"Narragansett Villages": POSTNARRAGANSETTVILLAGES
};
//control for map layers (both base map and points)
var layersControl = L.control.layers(baseMaps, preOverlayMaps).addTo(mymap);
//Defining map legend (shows up in bottom left corner)
var legend = L.control({position: "bottomleft"}); //legend for colors
var legend2 = L.control({position: "bottomright"}); //legend for symbols/icons
//Defining text and colors to show for the Color legend
legend.onAdd = function(map) {
var div = L.DomUtil.create("div", "legend");
div.innerHTML += "<h4>Color Legend</h4>";
div.innerHTML += '<i style="background: #CB2B3E"></i> <span>Colonist Town</span><br>';
div.innerHTML += '<i style="background: #2A81CB"></i> <span>Praying Town (Old)</span><br>';
div.innerHTML += '<i style="background: #2AAD27"></i> <span>Praying Town (New)</span><br>';
div.innerHTML += '<i style="background: #9C2BCB"></i> <span>Indian Internment or Slavery Location</span><br>';
div.innerHTML += '<i style="background: #FFD326"></i> <span>Nipmuc Village</span><br>';
div.innerHTML += '<i style="background: #CAC428"></i> <span>Narragansett Village</span><br>';
div.innerHTML += '<i style="background: #CB8427"></i> <span>Wampanoag Village</span><br>';
return div;
};
//add this color legend to the map
legend.addTo(mymap);
//Defining text and icons to show for the Symbol legend
legend2.onAdd = function(map) {
var div = L.DomUtil.create("div", "legend");
div.innerHTML += "<h4>Symbol Legend</h4>";
div.innerHTML += '<img src="icons/colonist/colonistmeetinghouse.png" width="30"> <span>Colonist Town</span><br>';
div.innerHTML += '<img src="icons/wetu/wetu-icon.png" width="30"> <span>Indian Village</span><br>';
div.innerHTML += '<img src="icons/eliot/eliot-church-icon-final.png" width="30"> <span>Praying Town</span><br>'
div.innerHTML += '<img src="icons/violence/violenceicon.png" width="30"> <span>Location of Violence</span><br>';
div.innerHTML += '<img src="icons/corn/cornicon.png" width="30"> <span>Indian Planting Field</span><br>';
div.innerHTML += '<img src="icons/canoe/canoeiconfinal.png" width="30"> <span>Indian Fishing Spot</span><br>';
div.innerHTML += '<img src="icons/shackles/shackle-iconfinal.png" width="30"> <span>Internment or Slavery</span><br>';
return div;
};
//add this symbol legend to the map
legend2.addTo(mymap);
//These three functions get called by the "time switcher" buttons underneath the map
//switch to "prewar" mode
function prewar(){
mymap.eachLayer(function (layer){ //remove all current layers from the map
mymap.removeLayer(layer);
});
mymap.addLayer(MAP); //add topographic baselayer
mymap.addLayer(preLayerGroup); //add the layer group with appropriate prewar layers
mymap.removeControl(layersControl); //remove current layer control
layersControl = L.control.layers(baseMaps, preOverlayMaps).addTo(mymap); //add new appropriate layer control
}
function wartime(){
mymap.eachLayer(function (layer){ //remove all current layers from the map
mymap.removeLayer(layer);
});
mymap.addLayer(MAP); //add topographic baselayer
mymap.addLayer(warLayerGroup); //add the layer group with appropriate prewar layers
mymap.removeControl(layersControl); //remove current layer control
layersControl = L.control.layers(baseMaps, warOverlayMaps).addTo(mymap); //add new appropriate layer control
}
function postwar(){
mymap.eachLayer(function (layer){ //remove all current layers from the map
mymap.removeLayer(layer);
});
mymap.addLayer(MAP); //add topographic baselayer
mymap.addLayer(postLayerGroup); //add the layer group with appropriate prewar layers
mymap.removeControl(layersControl); //remove current layer control
layersControl = L.control.layers(baseMaps, postOverlayMaps).addTo(mymap); //add new appropriate layer control
}
</script>
</body>
</html>