gpstrek - Fix current position marker placement

master
Martin Boonk 2023-05-21 16:04:48 +02:00
parent fcb1b0d15e
commit acfd5f1363
1 changed files with 12 additions and 11 deletions

View File

@ -241,6 +241,10 @@ let getMapSlice = function(){
let mapScale = isMapOverview ? mapOverviewScale : mapLiveScale; let mapScale = isMapOverview ? mapOverviewScale : mapLiveScale;
if (s.currentPos.lat) {
current = Bangle.project(s.currentPos);
}
const errorMarkerSize=3; const errorMarkerSize=3;
let compassHeight = height*0.4; let compassHeight = height*0.4;
if (!SETTINGS.mapCompass) compassHeight=0; if (!SETTINGS.mapCompass) compassHeight=0;
@ -337,19 +341,16 @@ let getMapSlice = function(){
graphics.setColor(graphics.theme.fg); graphics.setColor(graphics.theme.fg);
if (s.currentPos.lat) { if (s.currentPos.lat) {
current.x = startingPoint.x - current.x; let proj = Bangle.project(s.currentPos);
current.y = (startingPoint.y - current.y)*-1; let pos = graphics.transformVertices([ startingPoint.x - proj.x, (startingPoint.y - proj.y)*-1 ], mapTrans);
current.x *= mapScale;
current.y *= mapScale;
current.x += mapCenterX;
current.y += mapCenterY;
if (current.x < x) { current.x = x + errorMarkerSize + 5; graphics.setColor(1,0,0).fillRect(x,y,x+errorMarkerSize,y+height);}
if (current.x > x + width) {current.x = x + width - errorMarkerSize - 5; graphics.setColor(1,0,0).fillRect(x + width - errorMarkerSize,y,x + width ,y+height);}
if (current.y < y) {current.y = y + errorMarkerSize + 5; graphics.setColor(1,0,0).fillRect(x,y,x + width,y+errorMarkerSize);}
if (current.y > y + height) { current.y = y + height - errorMarkerSize - 5; graphics.setColor(1,0,0).fillRect(x,y + height - errorMarkerSize,x + width ,y+height);}
graphics.drawImage(arrow, current.x-arrow.width/2,current.y); if (pos[0] < x) { pos[0] = x + errorMarkerSize + 5; graphics.setColor(1,0,0).fillRect(x,y,x+errorMarkerSize,y+height);}
if (pos[0] > x + width) {pos[0] = x + width - errorMarkerSize - 5; graphics.setColor(1,0,0).fillRect(x + width - errorMarkerSize,y,x + width ,y+height);}
if (pos[1] < y) {pos[1] = y + errorMarkerSize + 5; graphics.setColor(1,0,0).fillRect(x,y,x + width,y+errorMarkerSize);}
if (pos[1] > y + height) { pos[1] = y + height - errorMarkerSize - 5; graphics.setColor(1,0,0).fillRect(x,y + height - errorMarkerSize,x + width ,y+height);}
graphics.drawImage(arrow, pos[0]-arrow.width/2,pos[1]);
graphics.setColor(0,1,0); graphics.setColor(0,1,0);
graphics.fillRect(mapCenterX-1,mapCenterY-1, mapCenterX+1,mapCenterY+1); graphics.fillRect(mapCenterX-1,mapCenterY-1, mapCenterX+1,mapCenterY+1);
graphics.setColor(graphics.theme.fg); graphics.setColor(graphics.theme.fg);