-
Notifications
You must be signed in to change notification settings - Fork 0
/
isolatesmap.js
89 lines (74 loc) · 2.63 KB
/
isolatesmap.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
83
84
85
86
87
88
89
function langMap(latitude,longitude, zoom) {
var map = L.map('map').setView([latitude,longitude], zoom);
L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', {
maxZoom: 18,
attribution: 'Map data © <a href="http://maps.google.com/">Google Maps</a>',
id: 'mapbox/light-v9',
subdomains:['mt0','mt1','mt2','mt3']
}).addTo(map);
/* L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
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>',
id: 'mapbox/streets-v11'
}).addTo(mymap);*/
function onEachFeature(feature, layer) {
var popupContent = feature.properties.family == null || feature.properties.family == "" ?
"<p><b>" + feature.properties.label + "</b><br/>Family: Isolate</p>" :
"<p><b>" + feature.properties.label + "</b><br/>Family: " + feature.properties.family + "</p>";
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
if (feature.properties && feature.properties.family != null) {
if (!familyList.has(feature.properties.family)) {
familyList.add(feature.properties.family);
}
}
layer.bindPopup(popupContent);
}
var familyList = new Set()
function countLanguages(feature, layer) {
if (!familyList.has(feature.properties.family)) {
familyList.add(feature.properties.family);
}
}
L.geoJSON(languages, {
onEachFeature: countLanguages
});
var seq = palette('tol-rainbow', familyList.size);
var familyArray = Array.from(familyList);
var familyToColor = {};
for (i=0; i < familyArray.length; i++) {
familyToColor[familyArray[i]] = seq[i];
}
function pointToLayerFunc(feature, latlng) {
if (feature.properties.family == null || feature.properties.family == "" || feature.properties.family == "Isolate") {
return L.circleMarker(latlng, {
radius: 7,
fillColor: "#fff",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
else {
return L.circleMarker(latlng, {
radius: 7,
fillColor: "#" + familyToColor[feature.properties.family],
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
}
L.geoJSON(languages, {
style: function (feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature,
pointToLayer: pointToLayerFunc
}).addTo(map);
}