From 05745e22521a44657ed5bb6181067f8911d49164 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 27 Apr 2022 16:44:11 +0000 Subject: [PATCH] LazMapViewer: Repeat incomplete previous commit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8268 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/lazmapviewer/examples/fulldemo/main.pas | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/lazmapviewer/examples/fulldemo/main.pas b/components/lazmapviewer/examples/fulldemo/main.pas index 3278744d4..39607626f 100644 --- a/components/lazmapviewer/examples/fulldemo/main.pas +++ b/components/lazmapviewer/examples/fulldemo/main.pas @@ -134,11 +134,12 @@ type const MAX_LOCATIONS_HISTORY = 50; MAP_PROVIDER_FILENAME = 'map-providers.xml'; + HOMEDIR = '../../../../'; USE_DMS = true; var PointFormatSettings: TFormatsettings; - CacheDir: String = '../../../../'; // share the cache in both example projects + CacheDir: String = HOMEDIR + 'cache/'; // share the cache in both example projects function CalcIniName: String; @@ -340,7 +341,7 @@ begin fn := Application.Location + 'mapmarker.png'; if not FileExists(fn) then - MessageDlg('Copy the file "mapmarker.png" from the source to the app binary directory.', + MessageDlg('Copy the file "mapmarker.png" from the source folder to the folder with the executable.', mtError, [mbOK], 0) else begin @@ -350,8 +351,13 @@ begin POIImage.LoadFromFile(fn); end; - ForceDirectories(HOMEDIR + 'cache/'); - MapView.CachePath := HOMEDIR + 'cache/'; + CacheDir := HOMEDIR + 'cache/'; + if not ForceDirectories(CacheDir) then + begin + CacheDir := GetAppConfigDir(false) + 'cache/'; + ForceDirectories(CacheDir); + end; + MapView.CachePath := CacheDir; MapView.GetMapProviders(CbProviders.Items); CbProviders.ItemIndex := CbProviders.Items.Indexof(MapView.MapProvider); MapView.DoubleBuffered := true;