Phi: draw aircraft trail on map widget
This commit is contained in:
parent
ca3510aac1
commit
702cd2c8ea
1 changed files with 12 additions and 0 deletions
|
@ -110,6 +110,10 @@ define(
|
||||||
|
|
||||||
aircraftMarker.addTo(self.map);
|
aircraftMarker.addTo(self.map);
|
||||||
|
|
||||||
|
var aircraftTrack = L.polyline([], {
|
||||||
|
color : 'red'
|
||||||
|
}).addTo(self.map);
|
||||||
|
|
||||||
self.latitude = ko.observable(0).extend({
|
self.latitude = ko.observable(0).extend({
|
||||||
fgprop : 'latitude'
|
fgprop : 'latitude'
|
||||||
});
|
});
|
||||||
|
@ -142,10 +146,18 @@ define(
|
||||||
rateLimit : 2000
|
rateLimit : 2000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.aircraftTrailLength = 60;
|
||||||
|
|
||||||
self.mapCenter.subscribe(function(newValue) {
|
self.mapCenter.subscribe(function(newValue) {
|
||||||
if (self.followAircraft()) {
|
if (self.followAircraft()) {
|
||||||
self.map.setView(newValue);
|
self.map.setView(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var trail = aircraftTrack.getLatLngs();
|
||||||
|
while (trail.length > self.aircraftTrailLength)
|
||||||
|
trail.shift();
|
||||||
|
trail.push(newValue);
|
||||||
|
aircraftTrack.setLatLngs(trail);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue