diff --git a/components/lazmapviewer/examples/fulldemo/main.lfm b/components/lazmapviewer/examples/fulldemo/main.lfm index 884d7b1e5..d80916e43 100644 --- a/components/lazmapviewer/examples/fulldemo/main.lfm +++ b/components/lazmapviewer/examples/fulldemo/main.lfm @@ -1,7 +1,7 @@ object MainForm: TMainForm - Left = 332 + Left = 381 Height = 640 - Top = 183 + Top = 187 Width = 883 Caption = 'LazMapViewer' ClientHeight = 640 diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index 61fca3fc9..2a55d72f0 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -638,6 +638,7 @@ 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); @@ -645,6 +646,14 @@ begin else pixelLocation := DegreesToPixelsEPSG3857(AWin, ALonLat); end; Result.X := pixelLocation.x + AWin.X; + if FCyclic and CrossesDateline then + begin + mapWidth := ZoomFactor(AWin.Zoom) * TILE_SIZE; + while (Result.X < 0) do + Result.X := Result.X + mapWidth; + while (Result.X > AWin.Width) do + Result.X := Result.X - mapWidth; + end; Result.Y := pixelLocation.y + AWin.Y; end; @@ -729,16 +738,16 @@ var begin mapWidth := round(ZoomFactor(AWin.Zoom)) * TILE_SIZE; - mPoint.Y := EnsureRange(APoint.Y - AWin.Y, 0, mapWidth); - mPoint.X := EnsureRange(APoint.X - AWin.X, 0, mapWidth); if FCyclic then begin + mPoint.X := (APoint.X - AWin.X) mod mapWidth; while mPoint.X < 0 do mPoint.X := mPoint.X + mapWidth; while mPoint.X >= mapWidth do mPoint.X := mPoint.X - mapWidth; - mPoint.Y := EnsureRange(APoint.Y - AWin.Y, 0, mapWidth); - end; + end else + mPoint.X := EnsureRange(APoint.X - AWin.X, 0, mapWidth); + mPoint.Y := EnsureRange(APoint.Y - AWin.Y, 0, mapWidth); case aWin.MapProvider.ProjectionType of ptEPSG3857: Result := PixelsToDegreesEPSG3857(mPoint, AWin.Zoom); diff --git a/components/lazmapviewer/source/mvgpsobj.pas b/components/lazmapviewer/source/mvgpsobj.pas index 4a377c5f3..5062934e5 100644 --- a/components/lazmapviewer/source/mvgpsobj.pas +++ b/components/lazmapviewer/source/mvgpsobj.pas @@ -216,7 +216,7 @@ var i: integer; begin Result.Init(0, 0, 0, 0); - if Objs.Count>0 then + if Objs.Count > 0 then begin Result := Objs[0].BoundingBox; for i:=1 to pred(Objs.Count) do diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index d435658b5..d13ad2e29 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -280,7 +280,7 @@ constructor TDrawObjJob.Create(aViewer: TMapView; aLst: TGPSObjList; begin FArea := aArea; FLst := aLst; - SetLEngth(FStates,FLst.Count); + SetLength(FStates, FLst.Count); Viewer := aViewer; AllRun := false; Name := 'DrawObj'; @@ -603,15 +603,15 @@ end; procedure TMapView.OnGPSItemsModified(Sender: TObject; objs: TGPSObjList; Adding: boolean); var - Area,ObjArea,vArea: TRealArea; + Area, objArea, visArea: TRealArea; begin if Adding and Assigned(Objs) then begin - ObjArea := GetAreaOf(Objs); - vArea := GetVisibleArea; - if hasIntersectArea(ObjArea,vArea) then + objArea := GetAreaOf(Objs); + visArea := GetVisibleArea; + if hasIntersectArea(objArea, visArea) then begin - Area := IntersectArea(ObjArea, vArea); + Area := IntersectArea(objArea, visArea); Engine.Jobqueue.AddJob(TDrawObjJob.Create(self, Objs, Area), Engine); end else @@ -719,6 +719,7 @@ begin if (APt.ExtraData <> nil) and APt.ExtraData.InheritsFrom(TDrawingExtraData) then ptColor := TDrawingExtraData(APt.ExtraData).Color; DrawingEngine.PenColor := ptColor; + DrawingEngine.PenWidth := 3; DrawingEngine.Line(pt.X, pt.Y - 5, pt.X, pt.Y + 5); DrawingEngine.Line(pt.X - 5, pt.Y, pt.X + 5, pt.Y); pt.Y := pt.Y + 5; @@ -734,7 +735,7 @@ begin s := ' ' + s + ' '; end; extent := DrawingEngine.TextExtent(s); - DrawingEngine.Textout(pt.X - extent.CX div 2, pt.Y + 5, s); + DrawingEngine.TextOut(pt.X - extent.CX div 2, pt.Y + 5, s); finally GPSItems.Unlock; end; @@ -767,6 +768,7 @@ begin DrawingEngine.DrawBitmap(Pt.X - FPOIImage.Width div 2, Pt.Y - FPOIImage.Height, FPOIImage, true) else begin DrawingEngine.PenColor := ptColor; + DrawingEngine.PenWidth := 3; DrawingEngine.Line(Pt.X, Pt.Y - 5, Pt.X, Pt.Y + 5); DrawingEngine.Line(Pt.X - 5, Pt.Y, Pt.X + 5, Pt.Y); Pt.Y := Pt.Y + 5; @@ -1025,14 +1027,19 @@ end; function TMapView.GetVisibleArea: TRealArea; var - aPt: TPoint; + mapWidth: Int64; begin - aPt.X := 0; - aPt.Y := 0; - Result.TopLeft := Engine.ScreenToLonLat(aPt); - aPt.X := Width; - aPt.Y := Height; - Result.BottomRight := Engine.ScreenToLonLat(aPt); + Result.TopLeft := Engine.ScreenToLonLat(Point(0, 0)); + Result.BottomRight := Engine.ScreenToLonLat(Point(Width, Height)); + if Cyclic then + begin + mapWidth := ZoomFactor(Engine.Zoom) * TILE_SIZE; + if Width >= mapWidth then + begin + Result.TopLeft.Lon := -180; + Result.BottomRight.Lon := 180; + end; + end; end; procedure TMapView.ClearBuffer;