show receiver location pin on the map
This commit is contained in:
parent
bdb6d75f83
commit
e062412e60
@ -30,6 +30,7 @@
|
||||
var map;
|
||||
var markers = {};
|
||||
var rectangles = {};
|
||||
var receiverMarker;
|
||||
var updateQueue = [];
|
||||
|
||||
// reasonable default; will be overriden by server
|
||||
@ -200,6 +201,7 @@
|
||||
var reset = function(callsign, item) { item.setMap(); };
|
||||
$.each(markers, reset);
|
||||
$.each(rectangles, reset);
|
||||
receiverMarker.setMap();
|
||||
markers = {};
|
||||
rectangles = {};
|
||||
};
|
||||
@ -227,12 +229,13 @@
|
||||
switch (json.type) {
|
||||
case "config":
|
||||
var config = json.value;
|
||||
if (!map) $.getScript("https://maps.googleapis.com/maps/api/js?key=" + config.google_maps_api_key).done(function(){
|
||||
map = new google.maps.Map($('.openwebrx-map')[0], {
|
||||
center: {
|
||||
var receiverPos = {
|
||||
lat: config.receiver_gps.lat,
|
||||
lng: config.receiver_gps.lon
|
||||
},
|
||||
};
|
||||
if (!map) $.getScript("https://maps.googleapis.com/maps/api/js?key=" + config.google_maps_api_key).done(function(){
|
||||
map = new google.maps.Map($('.openwebrx-map')[0], {
|
||||
center: receiverPos,
|
||||
zoom: 5,
|
||||
});
|
||||
|
||||
@ -245,7 +248,27 @@
|
||||
updateQueue = [];
|
||||
});
|
||||
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push($(".openwebrx-map-legend")[0]);
|
||||
|
||||
if (!receiverMarker) {
|
||||
receiverMarker = new google.maps.Marker();
|
||||
receiverMarker.addListener('click', function() {
|
||||
showReceiverInfoWindow(receiverMarker);
|
||||
});
|
||||
}
|
||||
receiverMarker.setOptions({
|
||||
map: map,
|
||||
position: receiverPos,
|
||||
title: config['receiver_name'],
|
||||
config: config
|
||||
});
|
||||
}); else {
|
||||
receiverMarker.setOptions({
|
||||
map: map,
|
||||
position: receiverPos,
|
||||
title: config['receiver_name'],
|
||||
config: config
|
||||
});
|
||||
}
|
||||
retention_time = config.map_position_retention_time * 1000;
|
||||
break;
|
||||
case "update":
|
||||
@ -344,6 +367,15 @@
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
|
||||
var showReceiverInfoWindow = function(marker) {
|
||||
var infowindow = getInfoWindow()
|
||||
infowindow.setContent(
|
||||
'<h3>' + marker.config['receiver_name'] + '</h3>' +
|
||||
'<div>Receiver location</div>'
|
||||
);
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
|
||||
var getScale = function(lastseen) {
|
||||
var age = new Date().getTime() - lastseen;
|
||||
var scale = 1;
|
||||
|
@ -426,7 +426,12 @@ class MapConnection(OpenWebRxClient):
|
||||
super().__init__(conn)
|
||||
|
||||
pm = Config.get()
|
||||
self.write_config(pm.filter("google_maps_api_key", "receiver_gps", "map_position_retention_time").__dict__())
|
||||
self.write_config(pm.filter(
|
||||
"google_maps_api_key",
|
||||
"receiver_gps",
|
||||
"map_position_retention_time",
|
||||
"receiver_name",
|
||||
).__dict__())
|
||||
|
||||
Map.getSharedInstance().addClient(self)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user