-
Notifications
You must be signed in to change notification settings - Fork 0
/
listeners_map.js
152 lines (142 loc) · 5.65 KB
/
listeners_map.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
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
// Used here: http://rxx.classaxe.com/en/rna/listeners/56/map
// Global vars:
// google.maps
// box, center, gridColor, gridOpacity, highlight, layers, map, markers
var LMap = {
markerGroups : null,
init : function() {
map = new google.maps.Map($('#map').get(0), {
center: { lat: center.lat, lng: center.lon },
scaleControl: true,
zoomControl: true,
zoom: 7
});
if (box[0].lat !== box[1].lat || box[0].lon !== box[1].lon) {
map.fitBounds(
new google.maps.LatLngBounds(
new google.maps.LatLng(box[0].lat, box[0].lon), //sw
new google.maps.LatLng(box[1].lat, box[1].lon) //ne
)
);
}
LMap.drawGrid();
LMap.drawMarkers();
LMap.setActions();
setExternalLinks();
setClippedCellTitles();
nite.init(map);
setInterval(function() { nite.refresh() }, 10000); // every 10s
},
drawGrid : function() {
return drawGrid(map, layers);
},
drawMarkers : function() {
var html, i, icon_highlight, icon_primary, icon_secondary, marker;
if (!listeners) {
return;
}
LMap.markerGroups=new google.maps.MVCObject();
LMap.markerGroups.set('primary', map);
LMap.markerGroups.set('secondary', map);
LMap.markerGroups.set('highlight', map);
icon_primary = {
url: base_image + '/map_point3.gif',
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(5, 5)
};
icon_secondary = {
url: base_image + '/map_point4.gif',
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(5, 5)
};
icon_highlight = {
url: base_image + '/map_point_here.gif',
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(6, 6)
};
html = '';
for (i in listeners) {
l = listeners[i];
html +=
'<tr id="listener_' + l.id + '" class="qth_' + (l.pri ? 'pri' : 'sec') + '" data-gmap="' + l.lat + '|' + l.lon + '">' +
'<td class="text-nowrap" data-val="' + l.name + '">' +
'<img style="display:block;float: left" src="' + base_image + '/map_point' + (l.pri ? 3 : 4) + '.gif" alt="' + (l.pri ? msg.qth_pri : msg.qth_sec) + '" />' +
'<a href="' + base_url + 'listeners/' + l.id + '" class="' + (l.pri ? 'pri' : 'sec') + '" data-popup="1">' +
l.name +
'</a></td>' +
'<td data-val="' + l.qth + '">' + l.qth + '</td>' +
'<td data-val="' + l.sp + '">' + l.sp + '</td>' +
'<td data-val="' + l.itu + '">' + l.itu + '</td>' +
'</tr>';
marker = new google.maps.Marker({
id: 'point_' + l.id,
icon: (l.pri ? icon_primary : icon_secondary),
position: new google.maps.LatLng(l.lat, l.lon),
title: (decodeHtmlEntities(l.name) + ': ' + decodeHtmlEntities(l.qth) + (l.sp ? ', ' + l.sp : '') + ', ' + l.itu)
});
marker.bindTo('map', LMap.markerGroups, (l.pri ? 'primary' : 'secondary'));
markers.push(marker);
}
for (i in markers) {
markers[i].addListener('mouseover', function() {
$('#listener_' + this.id.split('_')[1]).css('background', '#ffff00');
});
markers[i].addListener('mouseout', function () {
$('#listener_' + this.id.split('_')[1]).css('background', '');
});
markers[i].addListener('click', function () {
$('#listener_' + this.id.split('_')[1]).find('a').trigger('click');
});
}
$('#markerlist tbody').append(html);
$('tr[data-gmap]')
.mouseover(function() {
var coords = $(this).data('gmap').split('|');
highlight = new google.maps.Marker({
position: new google.maps.LatLng(coords[0], coords[1]),
map: map,
icon: icon_highlight
});
})
.mouseout(function() {
highlight.setMap(null);
});
$('.no-results').hide();
$('#markerlist').show();
},
setActions : function() {
$('#layer_grid').click(function() {
var active, i;
active = $('#layer_grid').prop('checked');
for (i in layers.grid) {
layers.grid[i].setMap(active ? map : null);
}
});
$('#layer_night').click(function () {
if ($('#layer_night').prop('checked')) {
nite.show()
} else {
nite.hide();
}
});
$('#layer_primary').click(function() {
var layer_primary = $('#layer_primary');
LMap.markerGroups.set('primary', layer_primary.prop('checked') ? map : null);
if (layer_primary.prop('checked')) {
$('#markerlist .qth_pri').show();
} else {
$('#markerlist .qth_pri').hide();
}
});
$('#layer_secondary').click(function() {
var layer_secondary = $('#layer_secondary');
LMap.markerGroups.set('secondary', layer_secondary.prop('checked') ? map : null);
if (layer_secondary.prop('checked')) {
$('#markerlist .qth_sec').show();
} else {
$('#markerlist .qth_sec').hide();
}
});
mapMarkerColSetActions();
}
};