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