X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=blobdiff_plain;f=js%2Fmap.js;h=3cc00c5384c6fd6b97bbf00496a5d91404819f6b;hp=716a0166db49a22a0278a605f73e20d20515766f;hb=6ddefbf98ebff13592de1d87a3bfc2796ac06d84;hpb=582d50fc8e75b19c1d07625d4ce759ea422b08f5 diff --git a/js/map.js b/js/map.js index 716a016..3cc00c5 100644 --- a/js/map.js +++ b/js/map.js @@ -135,8 +135,10 @@ function loadPrefs(aEvent) { gPrefs.get("position", function(aValue) { if (aValue) { gPos = aValue; - gWaitCounter--; } + gWaitCounter--; + var throwEv = new CustomEvent("prefs-step"); + gAction.dispatchEvent(throwEv); }); gWaitCounter++; gPrefs.get("center_map", function(aValue) { @@ -160,15 +162,26 @@ function loadPrefs(aEvent) { 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); }); } } @@ -353,6 +366,10 @@ function drawMap(aPixels, aOverdraw) { } } } + drawTrack(); +} + +function drawTrack() { gLastDrawnPoint = null; gCurPosMapCache = undefined; gTrackContext.clearRect(0, 0, gTrackCanvas.width, gTrackCanvas.height); @@ -754,7 +771,7 @@ function endTracking() { function clearTrack() { gTrack = []; gTrackStore.clear(); - drawMap({left: 0, right: 0, top: 0, bottom: 0}); + drawTrack(); } var gTileService = {