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;
var
pixelLocation: TPoint;
mapWidth: Int64;
begin
case AWin.MapProvider.ProjectionType of
ptEPSG3395: pixelLocation := DegreesToPixelsEPSG3395(AWin, ALonLat);
ptEPSG3857: pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat);
else pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat);
end;
mapWidth := ZoomFactor(AWin.Zoom) * TILE_SIZE;
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;
end;

View File

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