-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
61 lines (54 loc) · 1.8 KB
/
script.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
$('#map').height($(window).height() * .75)
var map, selectedViolation
DG.then(function () {
map = DG.map('map', {
fullscreenControl: false,
center: geoCenter,
zoom: geoZoom
})
var selectedIcon = DG.icon({
iconUrl: 'img/active.png',
iconSize: [22, 34]
})
var inactiveIcon = DG.icon({
iconUrl: 'img/inactive.png',
iconSize: [22, 34]
})
var visitedIcon = DG.icon({
iconUrl: 'img/visited.png',
iconSize: [22, 34]
})
var markerList = []
for (var category of data) {
for (var place of category.list) {
var opts = {}
if ('status' in place) {
switch (place.status) {
case 'inactive':
opts.icon = inactiveIcon
break
case 'visited':
opts.icon = visitedIcon
break
}
}
var marker = DG.marker([place.x, place.y], opts).bindPopup(place.name)
markerList.push(marker)
}
}
var group = DG.featureGroup(markerList).addTo(map)
DG.control.location({position: 'topleft'}).addTo(map)
$('a.list-group-item').on('click', function () {
if (undefined !== selectedViolation) selectedViolation.removeFrom(map)
var label = $('span.label', this).text()
var coordinates = $(this).data('geo').split(',').map(function (item) {
return parseFloat(item.trim())
})
selectedViolation = DG.marker(coordinates, {icon: selectedIcon}).addTo(map).bindLabel(label)
map.setView(coordinates)
$list.find('a.list-group-item').each(function () {
$(this).removeClass('active')
})
$(this).toggleClass('active')
})
})