+function drawCurrentLocation(trackPoint) {
+ var locpoint = gps2xy(trackPoint.coords.latitude, trackPoint.coords.longitude);
+ var circleRadius = Math.round(gCurLocSize / 2);
+ var mappos = {x: Math.round((locpoint.x - gPos.x) / gZoomFactor + gMapCanvas.width / 2),
+ y: Math.round((locpoint.y - gPos.y) / gZoomFactor + gMapCanvas.height / 2)};
+
+ undrawCurrentLocation();
+
+ // Cache overdrawn area.
+ gCurPosMapCache =
+ {point: locpoint,
+ radius: circleRadius,
+ data: gTrackContext.getImageData(mappos.x - circleRadius,
+ mappos.y - circleRadius,
+ circleRadius * 2, circleRadius * 2)};
+
+ gTrackContext.strokeStyle = gCurLocColor;
+ gTrackContext.fillStyle = gTrackContext.strokeStyle;
+ gTrackContext.beginPath();
+ gTrackContext.arc(mappos.x, mappos.y,
+ circleRadius, 0, Math.PI * 2, false);
+ gTrackContext.fill();
+}
+
+function undrawCurrentLocation() {
+ if (gCurPosMapCache) {
+ var oldpoint = gCurPosMapCache.point;
+ var oldmp = {x: Math.round((oldpoint.x - gPos.x) / gZoomFactor + gMapCanvas.width / 2),
+ y: Math.round((oldpoint.y - gPos.y) / gZoomFactor + gMapCanvas.height / 2)};
+ gTrackContext.putImageData(gCurPosMapCache.data,
+ oldmp.x - gCurPosMapCache.radius,
+ oldmp.y - gCurPosMapCache.radius);
+ gCurPosMapCache = undefined;
+ }
+}
+