diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index d41736509..6bd41c7a2 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -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; diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index 36b8545a3..ca9598d8e 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -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);