From 6b48ad28ce7ba8b9b5da31c3057a498de2e8fb87 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 27 Apr 2022 16:28:40 +0000 Subject: [PATCH] LazMapViewer: Fix write-permission and file-not-found issues in fulldemo on Mac. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8267 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../lazmapviewer/examples/fulldemo/main.lfm | 18 ++++++++++++++++++ .../lazmapviewer/examples/fulldemo/main.pas | 19 ++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/components/lazmapviewer/examples/fulldemo/main.lfm b/components/lazmapviewer/examples/fulldemo/main.lfm index d8cf53276..382a0e2dd 100644 --- a/components/lazmapviewer/examples/fulldemo/main.lfm +++ b/components/lazmapviewer/examples/fulldemo/main.lfm @@ -77,6 +77,7 @@ object MainForm: TMainForm BorderSpacing.Left = 6 BorderSpacing.Top = 6 Caption = 'Zoom:' + ParentColor = False end object CbMouseCoords: TGroupBox AnchorSideLeft.Control = PgData @@ -107,6 +108,7 @@ object MainForm: TMainForm BorderSpacing.Left = 8 BorderSpacing.Top = 4 Caption = 'Longitude' + ParentColor = False end object LblPositionLatitude: TLabel AnchorSideLeft.Control = CbMouseCoords @@ -120,6 +122,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Bottom = 8 Caption = 'Latitude' + ParentColor = False end object InfoPositionLongitude: TLabel AnchorSideLeft.Control = CbMouseCoords @@ -135,6 +138,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Right = 16 Caption = 'Label2' + ParentColor = False end object InfoPositionLatitude: TLabel AnchorSideLeft.Control = CbMouseCoords @@ -152,6 +156,7 @@ object MainForm: TMainForm BorderSpacing.Right = 16 BorderSpacing.Bottom = 8 Caption = 'Label2' + ParentColor = False end end object GbCenterCoords: TGroupBox @@ -181,6 +186,7 @@ object MainForm: TMainForm BorderSpacing.Left = 8 BorderSpacing.Top = 4 Caption = 'Longitude' + ParentColor = False end object LblCenterLatitude: TLabel AnchorSideLeft.Control = GbCenterCoords @@ -194,6 +200,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Bottom = 8 Caption = 'Latitude' + ParentColor = False end object InfoCenterLongitude: TLabel AnchorSideLeft.Control = GbCenterCoords @@ -209,6 +216,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Right = 16 Caption = 'Label2' + ParentColor = False end object InfoCenterLatitude: TLabel AnchorSideLeft.Control = GbCenterCoords @@ -226,6 +234,7 @@ object MainForm: TMainForm BorderSpacing.Right = 16 BorderSpacing.Bottom = 8 Caption = 'Label2' + ParentColor = False end end object GbScreenSize: TGroupBox @@ -255,6 +264,7 @@ object MainForm: TMainForm BorderSpacing.Left = 8 BorderSpacing.Top = 4 Caption = 'Width' + ParentColor = False end object LblViewportHeight: TLabel AnchorSideLeft.Control = GbScreenSize @@ -268,6 +278,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Bottom = 8 Caption = 'Height' + ParentColor = False end object InfoViewportWidth: TLabel AnchorSideTop.Control = GbScreenSize @@ -282,6 +293,7 @@ object MainForm: TMainForm BorderSpacing.Top = 4 BorderSpacing.Right = 16 Caption = 'Label2' + ParentColor = False end object InfoViewportHeight: TLabel AnchorSideTop.Control = InfoViewportWidth @@ -298,6 +310,7 @@ object MainForm: TMainForm BorderSpacing.Right = 16 BorderSpacing.Bottom = 8 Caption = 'Label2' + ParentColor = False end end object CbDistanceUnits: TComboBox @@ -385,6 +398,7 @@ object MainForm: TMainForm Width = 177 BorderSpacing.Top = 8 Caption = 'Select one of the found locations:' + ParentColor = False end object BtnGoTo: TButton AnchorSideTop.Control = CbFoundLocations @@ -470,6 +484,7 @@ object MainForm: TMainForm BorderSpacing.Left = 8 BorderSpacing.Top = 4 Caption = 'Click with right mouse button to add a GPS point.'#13#10'Settings on page "Config".' + ParentColor = False WordWrap = True end object GPSPointInfo: TLabel @@ -489,6 +504,7 @@ object MainForm: TMainForm BorderSpacing.Top = 16 BorderSpacing.Right = 6 Caption = 'GPSPointInfo' + ParentColor = False WordWrap = True end end @@ -535,6 +551,7 @@ object MainForm: TMainForm BorderSpacing.Top = 8 Caption = 'Providers:' FocusControl = CbProviders + ParentColor = False end object CbProviders: TComboBox AnchorSideLeft.Control = PgConfig @@ -743,6 +760,7 @@ object MainForm: TMainForm Width = 39 BorderSpacing.Left = 8 Caption = 'Backgr.' + ParentColor = False end object Bevel1: TBevel AnchorSideLeft.Control = CbDebugTiles diff --git a/components/lazmapviewer/examples/fulldemo/main.pas b/components/lazmapviewer/examples/fulldemo/main.pas index 5514f99c3..3278744d4 100644 --- a/components/lazmapviewer/examples/fulldemo/main.pas +++ b/components/lazmapviewer/examples/fulldemo/main.pas @@ -133,12 +133,12 @@ type const MAX_LOCATIONS_HISTORY = 50; - HOMEDIR = '../../../../'; // share the cache in both example projects MAP_PROVIDER_FILENAME = 'map-providers.xml'; USE_DMS = true; var PointFormatSettings: TFormatsettings; + CacheDir: String = '../../../../'; // share the cache in both example projects function CalcIniName: String; @@ -333,13 +333,22 @@ begin end; procedure TMainForm.FormCreate(Sender: TObject); +var + fn: String; begin cInputQueryEditSizePercents := 0; - // FMapMarker := CreateMapMarker(32, clRed, clBlack); - POIImage := TPortableNetworkGraphic.Create; - POIImage.PixelFormat := pf32bit; - POIImage.LoadFromFile('../../mapmarker.png'); + fn := Application.Location + 'mapmarker.png'; + if not FileExists(fn) then + MessageDlg('Copy the file "mapmarker.png" from the source to the app binary directory.', + mtError, [mbOK], 0) + else + begin + // FMapMarker := CreateMapMarker(32, clRed, clBlack); + POIImage := TPortableNetworkGraphic.Create; + POIImage.PixelFormat := pf32bit; + POIImage.LoadFromFile(fn); + end; ForceDirectories(HOMEDIR + 'cache/'); MapView.CachePath := HOMEDIR + 'cache/';