-
Notifications
You must be signed in to change notification settings - Fork 19
/
tsm.js
107 lines (89 loc) · 2.64 KB
/
tsm.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var map;
var defaultMarker, thingsMarker, placesMarker, citationMarker, scienceMarker, plusMarker, otherChannelMarker;
$(document).ready(function(){
if ( $( "#map" ).length ) {
// create a map in the "map" div, set the view to a given place and zoom
map = L.map('map').setView([35,15], 2);
// add an OpenStreetMap tile layer
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
generateIcons();
$.getJSON("data.json", function(json) {
jQuery.each(json.data, function() {
if(this.lat && this.long){
var text = '<div class="bubble"><a href="https://www.youtube.com/watch?v='+this.id+'"><b>'+this.title+'</b></a><br /><br /><a href="https://www.youtube.com/watch?v='+this.id+'"><img src="https://img.youtube.com/vi/'+this.id+'/mqdefault.jpg" /></a>'+this.comment+'</div>';
var marker = L.marker([this.lat, this.long],{icon:getIcon(this.category)}).bindPopup(text).openPopup().addTo(map);
}
});
});
}
});
function generateIcons(){
defaultMarker = L.AwesomeMarkers.icon({
icon: 'asterisk',
markerColor: 'darkred',
prefix: 'fa'
});
thingsMarker = L.AwesomeMarkers.icon({
icon: 'lightbulb-o',
markerColor: 'darkred',
prefix: 'fa'
});
placesMarker = L.AwesomeMarkers.icon({
icon: 'compass',
markerColor: 'darkred',
prefix: 'fa'
});
citationMarker = L.AwesomeMarkers.icon({
icon: 'quote-right',
markerColor: 'darkred',
prefix: 'fa'
});
scienceMarker = L.AwesomeMarkers.icon({
icon: 'flask',
markerColor: 'darkred',
prefix: 'fa'
});
parkMarker = L.AwesomeMarkers.icon({
icon: 'asterisk',
markerColor: 'blue',
prefix: 'fa'
});
plusMarker = L.AwesomeMarkers.icon({
icon: 'plus',
markerColor: 'darkblue',
prefix: 'fa'
});
techdifMarker = L.AwesomeMarkers.icon({
icon: 'warning',
markerColor: 'green',
prefix: 'fa'
});
otherChannelMarker = L.AwesomeMarkers.icon({
icon: 'asterisk',
markerColor: 'orange',
prefix: 'fa'
});
}
function getIcon(category){
if(category == "Things"){
return thingsMarker;
}else if(category == "Places"){
return placesMarker;
}else if(category == "Citation"){
return citationMarker;
}else if(category == "OtherChannel"){
return otherChannelMarker;
}else if(category == "ParkBench"){
return parkMarker;
}else if(category == "BuiltForScience"){
return scienceMarker;
}else if(category == "Plus"){
return plusMarker;
}else if(category == "TechDif"){
return techdifMarker;
}else{
return defaultMarker;
}
}