gPrefs.get("position", function(aValue) {
if (aValue) {
gPos = aValue;
- gWaitCounter--;
- var throwEv = new CustomEvent("prefs-step");
- gAction.dispatchEvent(throwEv);
}
+ gWaitCounter--;
+ var throwEv = new CustomEvent("prefs-step");
+ gAction.dispatchEvent(throwEv);
});
gWaitCounter++;
gPrefs.get("center_map", function(aValue) {
gAction.dispatchEvent(throwEv);
});
gWaitCounter++;
- gTrackStore.getList(function(aTPoints) {
- if (gDebug)
- console.log(aTPoints.length + " points loaded.");
- if (aTPoints.length) {
- gTrack = aTPoints;
+ var trackLoadStarted = false;
+ gTrackStore.getListStepped(function(aTPoint) {
+ if (aTPoint) {
+ // Add in front and return new length.
+ var tracklen = gTrack.unshift(aTPoint);
+ // Redraw track every 100 values (initial paint will do first anyhow).
+ if (tracklen % 100 == 0)
+ drawTrack();
+ }
+ else {
+ // Last point received.
+ drawTrack();
+ }
+ if (!trackLoadStarted) {
+ // We have the most recent point, if present, rest will load async.
+ trackLoadStarted = true;
+ gWaitCounter--;
+ var throwEv = new CustomEvent("prefs-step");
+ gAction.dispatchEvent(throwEv);
}
- gWaitCounter--;
- var throwEv = new CustomEvent("prefs-step");
- gAction.dispatchEvent(throwEv);
});
}
}
}
}
}
+ drawTrack();
+}
+
+function drawTrack() {
gLastDrawnPoint = null;
gCurPosMapCache = undefined;
gTrackContext.clearRect(0, 0, gTrackCanvas.width, gTrackCanvas.height);
function clearTrack() {
gTrack = [];
gTrackStore.clear();
- drawMap({left: 0, right: 0, top: 0, bottom: 0});
+ drawTrack();
}
var gTileService = {