1
0
Fork 0

Phi: use new pagedPathForHistory for the Map

This commit is contained in:
Torsten Dreyer 2015-03-03 17:13:52 +01:00
parent 5dbf68f25e
commit ad48e6f825
2 changed files with 30 additions and 6 deletions

View file

@ -405,6 +405,6 @@ require([
}; };
ko.applyBindings(new PhiViewModel()); ko.applyBindings(new PhiViewModel(),document.getElementById('wrapper'));
}); });

View file

@ -6,16 +6,43 @@ define([
var self = this; var self = this;
var trackLayer = new L.GeoJSON(null, {}); var trackLayer = new L.GeoJSON(null, {});
trackLayer.maxTrackPoints = 1000;
trackLayer.track = {
"type" : "Feature",
"geometry" : {
"type" : "LineString",
"coordinates" : []
},
"properties" : {
"type" : "FlightHistory",
"last" : 0
}
}
trackLayer.update = function(id) { trackLayer.update = function(id) {
var self = this; var self = this;
if (id != self.updateId) if (id != self.updateId)
return; return;
var url = "/flighthistory/track.json"; var url = "/flighthistory/track.json?count=" + self.maxTrackPoints + "&last=" + trackLayer.track.properties.last;
var jqxhr = $.get(url).done(function(data) { var jqxhr = $.get(url).done(function(data) {
self.clearLayers(); self.clearLayers();
self.addData(data); Array.prototype.push.apply(trackLayer.track.geometry.coordinates, data.geometry.coordinates);
if (data.properties) {
trackLayer.track.properties.last = data.properties.last || 0;
}
self.addData(trackLayer.track);
// update fast until we have all points
var updateDelay = data.geometry.coordinates.length < self.maxTrackPoints ? 120000 : 200;
setTimeout(function() {
self.update(id)
}, updateDelay);
}).fail(function() { }).fail(function() {
var r = confirm("Error loading flight history. Retry?"); var r = confirm("Error loading flight history. Retry?");
if (!r) if (!r)
@ -23,9 +50,6 @@ define([
}).always(function() { }).always(function() {
}); });
setTimeout(function() {
self.update(id)
}, 10000);
} }
trackLayer.updateId = 0; trackLayer.updateId = 0;