implement icon rotation

This commit is contained in:
Jakob Ketterl 2019-09-19 02:25:32 +02:00
parent 15c28b130d
commit ecbae5af2d
3 changed files with 19 additions and 11 deletions

View File

@ -14,6 +14,16 @@ AprsMarker.prototype.draw = function() {
div.style['background-position-y'] = -Math.floor(this.symbol.index / 16) * 24 + 'px';
}
if (this.course) {
if (this.course > 180) {
div.style.transform = 'scalex(-1) rotate(' + (270 - this.course) + 'deg)'
} else {
div.style.transform = 'rotate(' + (this.course - 90) + 'deg)';
}
} else {
div.style.transform = null;
}
if (this.symbol.table != '/' && this.symbol.table != '\\') {
overlay.style.display = 'block';
overlay.style['background-position-x'] = -(this.symbol.tableindex % 16) * 24 + 'px';
@ -33,8 +43,6 @@ AprsMarker.prototype.draw = function() {
AprsMarker.prototype.onAdd = function() {
var div = this.div = document.createElement('div');
div.className = 'marker';
div.style.position = 'absolute';
div.style.cursor = 'pointer';
div.style.width = '24px';

View File

@ -99,10 +99,12 @@
var pos = new google.maps.LatLng(update.location.lat, update.location.lon);
var marker;
var markerClass = google.maps.Marker;
var iconOptions = {}
var aprsOptions = {}
if (update.location.symbol) {
markerClass = AprsMarker;
iconOptions.symbol = update.location.symbol;
aprsOptions.symbol = update.location.symbol;
aprsOptions.course = update.location.course;
aprsOptions.speed = update.location.speed;
}
if (markers[update.callsign]) {
marker = markers[update.callsign];
@ -117,7 +119,7 @@
position: pos,
map: map,
title: update.callsign
}, iconOptions, getMarkerOpacityOptions(update.lastseen) ));
}, aprsOptions, getMarkerOpacityOptions(update.lastseen) ));
marker.lastseen = update.lastseen;
marker.mode = update.mode;
marker.band = update.band;

View File

@ -143,15 +143,13 @@ class WeatherParser(object):
class AprsLocation(LatLngLocation):
def __init__(self, data):
super().__init__(data["lat"], data["lon"])
self.comment = data["comment"] if "comment" in data else None
self.symbol = data["symbol"] if "symbol" in data else None
self.data = data
def __dict__(self):
res = super(AprsLocation, self).__dict__()
if self.comment is not None:
res["comment"] = self.comment
if self.symbol is not None:
res["symbol"] = self.symbol
for key in ["comment", "symbol", "course", "speed"]:
if key in self.data:
res[key] = self.data[key]
return res