* You can obtain one at http://mozilla.org/MPL/2.0/. */
var gMapCanvas, gMapContext, gTrackCanvas, gTrackContext, gGeolocation;
-var gDebug = true;
+var gDebug = false;
var gTileSize = 256;
var gMaxZoom = 18; // The minimum is 0.
gWaitCounter++;
gTrackStore.getList(function(aTPoints) {
if (gDebug)
- document.getElementById("debug").textContent = aTPoints.length + " points loaded.";
+ console.log(aTPoints.length + " points loaded.");
if (aTPoints.length) {
gTrack = aTPoints;
}
setTimeout(getPersistentPrefs, 100);
loopCnt++;
if (loopCnt > 50) {
- document.getElementById("debug").textContent = "Loading prefs failed.";
+ console.log("Loading prefs failed.");
}
};
getPersistentPrefs();
function resizeAndDraw() {
var viewportWidth = Math.min(window.innerWidth, window.outerWidth);
var viewportHeight = Math.min(window.innerHeight, window.outerHeight);
-
- gMapCanvas.width = viewportWidth;
- gMapCanvas.height = viewportHeight;
- gTrackCanvas.width = viewportWidth;
- gTrackCanvas.height = viewportHeight;
- drawMap();
- showUI();
+ if (gMapCanvas && gTrackCanvas) {
+ gMapCanvas.width = viewportWidth;
+ gMapCanvas.height = viewportHeight;
+ gTrackCanvas.width = viewportWidth;
+ gTrackCanvas.height = viewportHeight;
+ drawMap();
+ showUI();
+ }
}
function zoomIn() {
var iyMin = gPos.y - ht / 2;
var ixoff = Math.round((aCoords.x * size - ixMin) / gZoomFactor);
var iyoff = Math.round((aCoords.y * size - iyMin) / gZoomFactor);
+ // Would be nice to draw directly from the blob, but that crashes:
+ // gMapContext.drawImage(aImage, ixoff, iyoff);
var URL = window.URL;
var imgURL = URL.createObjectURL(aImage);
var imgObj = new Image();
imgObj.src = imgURL;
- gMapContext.drawImage(imgObj, ixoff, iyoff);
- URL.revokeObjectURL(imgURL);
+ imgObj.onload = function() {
+ gMapContext.drawImage(imgObj, ixoff, iyoff);
+ URL.revokeObjectURL(imgURL);
+ }
}
});
}
y: gPos.y + (x - gMapCanvas.height / 2) * gZoomFactor};
var gpsCoord = xy2gps(ptCoord.x, ptCoord.y);
var pt2Coord = gps2xy(gpsCoord.latitude, gpsCoord.longitude);
- document.getElementById("debug").textContent =
- ptCoord.x + "/" + ptCoord.y + " - " +
- gpsCoord.latitude + "/" + gpsCoord.longitude + " - " +
- pt2Coord.x + "/" + pt2Coord.y;
+ console.log(ptCoord.x + "/" + ptCoord.y + " - " +
+ gpsCoord.latitude + "/" + gpsCoord.longitude + " - " +
+ pt2Coord.x + "/" + pt2Coord.y);
*/
var newZoomLevel = gPos.z + (delta > 0 ? 1 : -1);
function(error) {
// Ignore erros for the moment, but this is good for debugging.
// See https://developer.mozilla.org/en/Using_geolocation#Handling_errors
- document.getElementById("debug").textContent = error.message;
+ if (gDebug)
+ console.log(error.message);
},
{enableHighAccuracy: true}
);