LazMapViewer: Fix markers disappearing occasionally if set near E/W border. Patch by Ekkehard Domning.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8796 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-04-20 13:32:52 +00:00
parent 68f653368d
commit df77354886
2 changed files with 12 additions and 7 deletions

View File

@@ -623,13 +623,20 @@ function TMapViewerEngine.DegreesToMapPixels(const AWin: TMapWindow;
ALonLat: TRealPoint): TPoint; ALonLat: TRealPoint): TPoint;
var var
pixelLocation: TPoint; pixelLocation: TPoint;
mapWidth: Int64;
begin begin
case AWin.MapProvider.ProjectionType of case AWin.MapProvider.ProjectionType of
ptEPSG3395: pixelLocation := DegreesToPixelsEPSG3395(AWin, ALonLat); ptEPSG3395: pixelLocation := DegreesToPixelsEPSG3395(AWin, ALonLat);
ptEPSG3857: pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat); ptEPSG3857: pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat);
else pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat); else pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat);
end; end;
mapWidth := ZoomFactor(AWin.Zoom) * TILE_SIZE;
Result.X := pixelLocation.x + AWin.X; Result.X := pixelLocation.x + AWin.X;
while (Result.X < 0) do
Result.X := Result.X + mapWidth;
while (Result.X > AWin.Width) do
Result.X := Result.X - mapWidth;
Result.Y := pixelLocation.y + AWin.Y; Result.Y := pixelLocation.y + AWin.Y;
end; end;

View File

@@ -788,16 +788,14 @@ end;
procedure TMapView.DrawObjects(const TileId: TTileId; procedure TMapView.DrawObjects(const TileId: TTileId;
aLeft, aTop,aRight,aBottom: integer); aLeft, aTop,aRight,aBottom: integer);
var var
aPt: TPoint;
Area: TRealArea; Area: TRealArea;
lst: TGPSObjList; lst: TGPSObjList;
begin begin
aPt.X := aLeft; Area.TopLeft := Engine.ScreenToLonLat(Point(aLeft, aTop));
aPt.Y := aTop; Area.BottomRight := Engine.ScreenToLonLat(Point(aRight, aBottom));
Area.TopLeft := Engine.ScreenToLonLat(aPt); while Area.BottomRight.Lon < Area.TopLeft.Lon do
aPt.X := aRight; Area.BottomRight.Lon := Area.BottomRight.Lon + 360.0;
aPt.Y := aBottom;
Area.BottomRight := Engine.ScreenToLonLat(aPt);
if GPSItems.Count > 0 then if GPSItems.Count > 0 then
begin begin
lst := GPSItems.GetObjectsInArea(Area); lst := GPSItems.GetObjectsInArea(Area);