pass through comments for display on the map

This commit is contained in:
Jakob Ketterl 2019-08-11 18:42:41 +02:00
parent e5dffc3d9f
commit 12c92928fa
3 changed files with 14 additions and 4 deletions

View File

@ -115,6 +115,7 @@
marker.lastseen = update.lastseen; marker.lastseen = update.lastseen;
marker.mode = update.mode; marker.mode = update.mode;
marker.band = update.band; marker.band = update.band;
marker.comment = update.location.comment;
// TODO the trim should happen on the server side // TODO the trim should happen on the server side
if (expectedCallsign && expectedCallsign == update.callsign.trim()) { if (expectedCallsign && expectedCallsign == update.callsign.trim()) {
@ -283,9 +284,14 @@
if (!infowindow) infowindow = new google.maps.InfoWindow(); if (!infowindow) infowindow = new google.maps.InfoWindow();
var marker = markers[callsign]; var marker = markers[callsign];
var timestring = moment(marker.lastseen).fromNow(); var timestring = moment(marker.lastseen).fromNow();
var commentString = "";
if (marker.comment) {
commentString = '<div>' + marker.comment + '</div>';
}
infowindow.setContent( infowindow.setContent(
'<h3>' + callsign + '</h3>' + '<h3>' + callsign + '</h3>' +
'<div>' + timestring + ' using ' + marker.mode + '</div>' '<div>' + timestring + ' using ' + marker.mode + '</div>' +
commentString
); );
infowindow.open(map, marker); infowindow.open(map, marker);
} }

View File

@ -91,7 +91,8 @@ class KissClient(object):
logger.debug(data) logger.debug(data)
if "lat" in data and "lon" in data: if "lat" in data and "lon" in data:
Map.getSharedInstance().updateLocation(data["source"], LatLngLocation(data["lat"], data["lon"]), "APRS") loc = LatLngLocation(data["lat"], data["lon"], data["comment"] if "comment" in data else None)
Map.getSharedInstance().updateLocation(data["source"], loc, "APRS")
return data return data
def parseAprsData(self, data): def parseAprsData(self, data):

View File

@ -92,12 +92,15 @@ class Map(object):
class LatLngLocation(Location): class LatLngLocation(Location):
def __init__(self, lat: float, lon: float): def __init__(self, lat: float, lon: float, comment = None):
self.lat = lat self.lat = lat
self.lon = lon self.lon = lon
self.comment = comment
def __dict__(self): def __dict__(self):
return {"type": "latlon", "lat": self.lat, "lon": self.lon} res = {"type": "latlon", "lat": self.lat, "lon": self.lon}
if self.comment is not None: res["comment"] = self.comment
return res
class LocatorLocation(Location): class LocatorLocation(Location):