diff --git a/components/lazmapviewer/examples/fulldemo/main.lfm b/components/lazmapviewer/examples/fulldemo/main.lfm index 2040f581c..884d7b1e5 100644 --- a/components/lazmapviewer/examples/fulldemo/main.lfm +++ b/components/lazmapviewer/examples/fulldemo/main.lfm @@ -19,6 +19,7 @@ object MainForm: TMainForm Width = 608 Align = alClient CachePath = '../../../../cache/' + Cyclic = True DefaultTrackColor = clBlue DefaultTrackWidth = 3 DownloadEngine = MapView.BuiltInDLE diff --git a/components/lazmapviewer/lazmapviewerpkg.lpk b/components/lazmapviewer/lazmapviewerpkg.lpk index 039b055cb..8642b0f99 100644 --- a/components/lazmapviewer/lazmapviewerpkg.lpk +++ b/components/lazmapviewer/lazmapviewerpkg.lpk @@ -10,6 +10,11 @@ + + + + + @@ -91,7 +96,7 @@ This is a fork of MapViewer by ti_dic (https://sourceforge.net/p/roadbook/code/c - + diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index f62c344f9..4c4317e47 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -59,6 +59,7 @@ type DragObj : TDragObj; Cache : TPictureCache; FActive: boolean; + FCyclic: Boolean; FDownloadEngine: TMvCustomDownloadEngine; FDrawTitleInGuiThread: boolean; FOnCenterMove: TNotifyEvent; @@ -82,7 +83,8 @@ type procedure SetActive(AValue: boolean); procedure SetCacheOnDisk(AValue: Boolean); procedure SetCachePath(AValue: String); - procedure SetCenter(aCenter: TRealPoint); + procedure SetCenter(ACenter: TRealPoint); + procedure SetCyclic(AValue: Boolean); procedure SetDownloadEngine(AValue: TMvCustomDownloadEngine); procedure SetHeight(AValue: integer); procedure SetMapProvider(AValue: String); @@ -118,6 +120,7 @@ type GetZStr: TGetValStr = nil): TMapProvider; procedure CancelCurrentDrawing; procedure ClearMapProviders; + function CrossesDateline: Boolean; procedure GetMapProviders(AList: TStrings); function LonLatToScreen(ALonLat: TRealPoint): TPoint; function LonLatToWorldScreen(ALonLat: TRealPoint): TPoint; @@ -146,6 +149,7 @@ type property Active: Boolean read FActive write SetActive default false; property CacheOnDisk: Boolean read GetCacheOnDisk write SetCacheOnDisk; property CachePath: String read GetCachePath write SetCachePath; + property Cyclic: Boolean read FCyclic write SetCyclic default false; property DownloadEngine: TMvCustomDownloadEngine read FDownloadEngine write SetDownloadEngine; property DrawTitleInGuiThread: boolean @@ -481,6 +485,17 @@ begin end; end; +{ Returns true when the visible window crosses the date line, i.e. the longitudes + at the left of the window are > 0, and those at the right are < 0. } +function TMapViewerEngine.CrossesDateline: Boolean; +var + visArea: TRealArea; +begin + visArea.TopLeft := ScreenToLonLat(Point(0, 0)); + visArea.BottomRight := ScreenToLonLat(Point(Width, Height)); + Result := (visArea.TopLeft.Lon > 0) and (visArea.BottomRight.Lon < 0); +end; + procedure TMapViewerEngine.DblClick(Sender: TObject); var pt: TPoint; @@ -1153,6 +1168,14 @@ begin end; end; +procedure TMapViewerEngine.SetCyclic(AValue: Boolean); +begin + if FCyclic = AValue then exit; + FCyclic := AValue; + if CrossesDateLine then + Redraw; +end; + procedure TMapViewerEngine.SetDownloadEngine(AValue: TMvCustomDownloadEngine); begin if FDownloadEngine = AValue then Exit; diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index dd582963a..d435658b5 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -60,6 +60,7 @@ Type function GetCacheOnDisk: boolean; function GetCachePath: String; function GetCenter: TRealPoint; + function GetCyclic: Boolean; function GetDownloadEngine: TMvCustomDownloadEngine; function GetDrawingEngine: TMvCustomDrawingEngine; function GetMapProvider: String; @@ -75,6 +76,7 @@ Type procedure SetCacheOnDisk(AValue: boolean); procedure SetCachePath(AValue: String); procedure SetCenter(AValue: TRealPoint); + procedure SetCyclic(AValue: Boolean); procedure SetDebugTiles(AValue: Boolean); procedure SetDefaultTrackColor(AValue: TColor); procedure SetDefaultTrackWidth(AValue: Integer); @@ -140,6 +142,7 @@ Type property Align; property CacheOnDisk: boolean read GetCacheOnDisk write SetCacheOnDisk default true; property CachePath: String read GetCachePath write SetCachePath stored IsCachePathStored; + property Cyclic: Boolean read GetCyclic write SetCyclic default false; property DebugTiles: Boolean read FDebugTiles write SetDebugTiles default false; property DefaultTrackColor: TColor read FDefaultTrackColor write SetDefaultTrackColor default clRed; property DefaultTrackWidth: Integer read FDefaultTrackWidth write SetDefaultTrackWidth default 1; @@ -319,6 +322,11 @@ begin Result := Engine.Center; end; +function TMapView.GetCyclic: Boolean; +begin + Result := Engine.Cyclic; +end; + function TMapView.GetDownloadEngine: TMvCustomDownloadEngine; begin if FDownloadEngine = nil then @@ -396,6 +404,11 @@ begin Engine.Center := AValue; end; +procedure TMapView.SetCyclic(AValue: Boolean); +begin + Engine.Cyclic := AValue; +end; + procedure TMapView.SetDebugTiles(AValue: Boolean); begin if FDebugTiles = AValue then exit;