diff --git a/htdocs/map.js b/htdocs/map.js index 708e665..fd3e740 100644 --- a/htdocs/map.js +++ b/htdocs/map.js @@ -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; + 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: { - lat: config.receiver_gps.lat, - lng: config.receiver_gps.lon - }, + 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( + '

' + marker.config['receiver_name'] + '

' + + '
Receiver location
' + ); + infowindow.open(map, marker); + } + var getScale = function(lastseen) { var age = new Date().getTime() - lastseen; var scale = 1; diff --git a/owrx/connection.py b/owrx/connection.py index c93290d..7939e1f 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -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)