-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmap.js
More file actions
37 lines (35 loc) · 1.4 KB
/
map.js
File metadata and controls
37 lines (35 loc) · 1.4 KB
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
var map = L.map('map').setView([42.359068001401006, -71.09147396226346], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
fetch('places.json')
.then(response => response.json())
.then(data => {
places = data;
places.forEach(place => {
optionalDescription = "";
if (place.description) {
optionalDescription = place.description + '<br>';
}
websiteHostOnly = place.website.replace('https://', '')
L.circleMarker([place.lat, place.lng], {
radius: place.size,
fillColor: '#000',
color: '#000',
weight: 2,
opacity: 1,
fillOpacity: 0.8
}).addTo(map)
.bindTooltip(place.name, {
permanent: true,
opacity: 0.8,
direction: 'right',
offset: [10, 0]
})
.bindPopup('<div style="text-align: center;">'
+ optionalDescription + '<a href="'
+ place.pics + '" target="_blank">Pics</a>'
+ '<br><a href="' + place.website + '" target="_blank">'
+ websiteHostOnly + '</a></div>');
});
});