LazMapViewer: Remove obsolete folder "fulldemo_with_addons" (project is in "fulldemo" now).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9331 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-04-09 23:00:17 +00:00
parent 0a49d28a19
commit 799dc2fec5
9 changed files with 0 additions and 2955 deletions

View File

@ -1,19 +0,0 @@
unit globals;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, mvEngine;
const
DistanceUnit_Names: array[TDistanceUnits] of string = ('m', 'km', 'miles');
var
DistanceUnit: TDistanceUnits = duKilometers;
implementation
end.

View File

@ -1,259 +0,0 @@
object GPSListViewer: TGPSListViewer
Left = 282
Height = 356
Top = 135
Width = 753
Caption = 'GPS points'
ClientHeight = 356
ClientWidth = 753
LCLVersion = '2.1.0.0'
object ListView: TListView
Left = 6
Height = 312
Top = 6
Width = 741
Align = alClient
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Checkboxes = True
Columns = <
item
Caption = 'ID'
end
item
Caption = 'Name'
Width = 150
end
item
Caption = 'Latitude'
Width = 150
end
item
Caption = 'Longitude'
Width = 150
end>
ReadOnly = True
RowSelect = True
TabOrder = 0
ViewStyle = vsReport
end
object Panel1: TPanel
Left = 0
Height = 38
Top = 318
Width = 753
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 38
ClientWidth = 753
TabOrder = 1
object BtnDeletePoint: TBitBtn
AnchorSideLeft.Control = BtnGoToPoint
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 118
Height = 26
Top = 6
Width = 110
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Delete point'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000002F2FE7433535D2FF2525D7450000000000000000000000002828
E8412F2FD1FF2525D74500000000000000000000000000000000000000000000
0000000000004141DEFF3838DBFF2F2FD4FF2626DD43000000002929EF402E2E
DDFF2C2CD8FF2F2FD1FF00000000000000000000000000000000000000000000
0000000000003F3FF1454040E5FF3636DEFF2D2DD9FF2929ED802A2AE3FF2B2B
E5FF2E2EDDFF2828E84100000000000000000000000000000000000000000000
000000000000000000003939F0433C3CE7FF3131E5FF2B2BE6FF2A2AE8FF2A2A
E3FF2929EF400000000000000000000000000000000000000000000000000000
00000000000000000000000000002B2BEF803131ECFF2C2CEBFF2B2BE6FF2929
ED80000000000000000000000000000000000000000000000000000000000000
000000000000000000002929EF403333ECFF2F2FEDFF3030ECFF3131E5FF2D2D
D9FF2626DD430000000000000000000000000000000000000000000000000000
0000000000003030EF413838E7FF3232EBFF3333ECFF2B2BEF803C3CE7FF3636
DEFF2F2FD4FF2525D74500000000000000000000000000000000000000000000
0000000000004242E5FF3D3DE9FF3838E7FF2929EF40000000003939F0434040
E5FF3838DBFF3535D2FF00000000000000000000000000000000000000000000
0000000000003F3FF1454242E5FF3030EF410000000000000000000000003F3F
F1454141DEFF2F2FE74300000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
}
OnClick = BtnDeletePointClick
TabOrder = 0
end
object BtnGoToPoint: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 6
Height = 26
Top = 6
Width = 106
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Go to point'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
000000000000000000000696F2DC0696F2500000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000069AF3A90694F2FF0697F18400000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000595F1350697F3FB05A2F4F50699F29E0080FF040000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000069BF3D802DBFBFF04B1F6F5059AF3C40099
EE0F000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000595F26004B0F6F200FEFFFF03BFF8F70699
F2DE0991EE1E0000000000000000000000000000000000000000000000000000
0000000000000000000000000000008EFF090698F2F301F1FDFF00FFFFFF03CF
F9FC0598F2EE0593F034000000000000000000000000000000000594F2620694
F2FF0694F2FF0694F2FF0694F2FF0694F2FF0694F2FF02D4FAFF00FFFFFF00FF
FFFF02DEFBFE0599F2F40696F2500000000000000000000000000080FF06059A
F3C204BDF7F600FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF
FFFF00FFFFFF01EBFDFF059DF4F50697F1840000000000000000000000000099
E60A069AF3D203C7F8F900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF
FFFF00FFFFFF00FFFFFF01F4FEFF05A5F5F40699F2A20099FF05000000000000
00000099F2140699F3E203CFF9FC00FFFFFF00FFFFFF00FFFFFF05A0F4FB0694
F2FF0694F2FF0694F2FF0694F2FF0694F2FF0694F2FF0594F262000000000000
0000000000000992F61C0598F3E902D7FAFD00FFFFFF00FFFFFF01E5FCFF0599
F2F40893F3420000000000000000000000000000000000000000000000000000
000000000000000000000791F1250599F2EF02E0FBFF00FFFFFF00FFFFFF01E5
FCFF0599F2F40893F34200000000000000000000000000000000000000000000
00000000000000000000000000000595F1350699F2F401E5FCFF00FFFFFF00FF
FFFF01E5FCFF0599F2F40893F342000000000000000000000000000000000000
0000000000000000000000000000000000000893F3420599F3F501EBFDFF00FF
FFFF00FFFFFF01E5FCFF0599F2F40893F3420000000000000000000000000000
000000000000000000000000000000000000000000000695F3570695F2FE0694
F2FF0694F2FF0694F2FF0694F2FF0695F2E50000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
}
OnClick = BtnGoToPointClick
TabOrder = 1
end
object BtnClose: TBitBtn
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 672
Height = 26
Top = 6
Width = 75
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Close'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000B6420000C1B40000CBD10000CDDD0000CBD10000
C1B40000B6420000000000000000000000000000000000000000000000000000
00000000BF040000BBA20000E0EE0000FFFF0000FFFF0000FFFF0000FFFF0000
FFFF0000E0EE0000BBA20000BF04000000000000000000000000000000000000
00000000BBA20000F2FC0000FFFF0000FCFF0000DFEF0000D2E10000E0EF0000
FCFF0000FFFF0000F2FC0000BBA2000000000000000000000000000000000000
B3430000E0EE0000FFFF0000EEF60000BFBB0000AE2C0000AA060000AA2D0000
BFBB0000EEF70000FFFF0000DFEE0000B4410000000000000000000000000000
C1B50000FFFF0000FCFF0000BFBA000000000000000000000000000000000000
00000000BFBB0000FCFF0000FFFF0000C1B40000000000000000000000000000
CBD20000FFFF0000DFEE0000AC2B000000000000000000000000000000000000
00000000AA2D0000DFEF0000FFFF0000CBD20000000000000000000000000000
CDDC0000FFFF0000D3E10000AA09000000000000000000000000000000000000
00000000AA090000D3E20000FFFF0000CEDB0000000000000000000000000000
CBCC0000FFFF0000E4F50000AC34000000000000B7E40000CEE00000B7E40000
00000000AF360000E4F40000FFFF0000CBCC0000000000000000000000000000
C0B30000FEFF0000FCFF0000BFBA000000000000CEE00000FFFF0000CEE00000
00000000C0BA0000FCFF0000FEFF0000C0B10000000000000000000000000000
B43A0000DFEE0000FFFF0000D2E30000B30A0000CEE00000FFFF0000CEE00000
00000000CDDA0000FFFF0000DEEE0000B3390000000000000000000000000000
00000000BC9B0000F1F90000D3E20000A20B0000CEE00000FFFF0000CEE00000
00000000CDDA0000F0FB0000BD9B000000000000000000000000000000000000
0000000080020000BC9F0000BBE90000A20B0000CEE00000FFFF0000CEE00000
00000000B9E40000BC9B00008002000000000000000000000000000000000000
000000000000000000000000AC34000080020000CEE00000FFFF0000CEE00000
00000000AC2B0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000CEE00000FFFF0000CEE00000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000B7E40000CEE00000B7E40000
0000000000000000000000000000000000000000000000000000
}
OnClick = BtnCloseClick
TabOrder = 2
end
object BtnCalcDistance: TButton
AnchorSideLeft.Control = BtnDeletePoint
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 234
Height = 25
Top = 6
Width = 203
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Calc distance between two points'
OnClick = BtnCalcDistanceClick
TabOrder = 3
end
object BtnSavePts: TButton
AnchorSideLeft.Control = BtnCalcDistance
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 443
Height = 25
Top = 6
Width = 86
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Save points'
OnClick = BtnSavePtsClick
TabOrder = 4
end
object BtnLoadTrack: TButton
AnchorSideLeft.Control = BtnSavePts
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 535
Height = 25
Top = 6
Width = 81
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Load track'
OnClick = BtnLoadTrackClick
TabOrder = 5
end
end
object SaveDialog: TSaveDialog
Title = 'Save gps points as'
DefaultExt = '.*.gps'
Filter = 'GPS points (*.gps)|*.gps|All files (*.*)|*.*'
left = 472
top = 256
end
object OpenDialog: TOpenDialog
Title = 'Open gps points file'
DefaultExt = '.gps'
Filter = 'GPS files (*.gps)|*.gps|All files (*.*)|*.*'
left = 560
top = 256
end
end

View File

@ -1,279 +0,0 @@
unit gpslistform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, ComCtrls,
ExtCtrls, Buttons, StdCtrls, mvGpsObj, mvMapViewer;
const
// IDs of GPS items
_CLICKED_POINTS_ = 10;
_TRACK_POINTS_ = 20;
type
{ TGPSListViewer }
TGPSListViewer = class(TForm)
BtnDeletePoint: TBitBtn;
BtnGoToPoint: TBitBtn;
BtnClose: TBitBtn;
BtnCalcDistance: TButton;
BtnSavePts: TButton;
BtnLoadTrack: TButton;
ListView: TListView;
OpenDialog: TOpenDialog;
Panel1: TPanel;
SaveDialog: TSaveDialog;
procedure BtnCalcDistanceClick(Sender: TObject);
procedure BtnCloseClick(Sender: TObject);
procedure BtnDeletePointClick(Sender: TObject);
procedure BtnGoToPointClick(Sender: TObject);
procedure BtnSavePtsClick(Sender: TObject);
procedure BtnLoadTrackClick(Sender: TObject);
private
FViewer: TMapView;
FList: TGpsObjList;
procedure SetViewer(AValue: TMapView);
protected
procedure Populate;
public
destructor Destroy; override;
property MapViewer: TMapView read FViewer write SetViewer;
end;
var
GPSListViewer: TGPSListViewer;
implementation
{$R *.lfm}
uses
mvTypes, mvEngine,
globals;
destructor TGPSListViewer.Destroy;
begin
FList.Free;
inherited;
end;
procedure TGPSListViewer.Populate;
var
i: Integer;
item: TListItem;
gpsObj: TGpsObj;
area: TRealArea;
begin
if FViewer = nil then begin
ListView.Items.Clear;
exit;
end;
FViewer.GPSItems.GetArea(area);
FList.Free;
FList := FViewer.GPSItems.GetObjectsInArea(area);
ListView.Items.BeginUpdate;
try
ListView.Items.Clear;
for i:=0 to FList.Count-1 do begin
gpsObj := FList[i];
item := ListView.Items.Add;
if gpsObj is TGpsPoint then begin
item.SubItems.Add(gpsObj.Name);
item.Subitems.Add(LatToStr(TGpsPoint(gpsObj).Lat, true));
item.Subitems.Add(LonToStr(TGpsPoint(gpsObj).Lon, true));
end;
end;
finally
ListView.Items.EndUpdate;
end;
end;
procedure TGPSListViewer.BtnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TGPSListViewer.BtnCalcDistanceClick(Sender: TObject);
type
TCoordRec = record
Lon: Double;
Lat: Double;
Name: String;
end;
var
i, iChecked: Integer;
item: TListItem;
rPt: TRealPoint;
CoordArr: array[0..1] of TCoordRec;
begin
// count checked items
iChecked := 0;
for i:=0 to ListView.Items.Count - 1 do begin
if ListView.Items.Item[i].Checked then Inc(iChecked);
end;
if iChecked <> 2 then begin
ShowMessage('Please select 2 items to calculate the distance.');
exit;
end;
iChecked := 0;
for i:=0 to ListView.Items.Count - 1 do begin
if ListView.Items.Item[i].Checked then begin
item := ListView.Items[i];
if TryStrToGps(item.SubItems[2], rPt.Lon) and TryStrToGps(item.SubItems[1], rPt.Lat) then
begin
CoordArr[iChecked].Lon := rPt.Lon;
CoordArr[iChecked].Lat := rPt.Lat;
CoordArr[iChecked].Name:= item.SubItems[0];
Inc(iChecked);
end;
end;
end;
// show distance between selected items
ShowMessage(Format('Distance between %s and %s is: %.2n %s.', [
CoordArr[0].Name, CoordArr[1].Name,
CalcGeoDistance(CoordArr[0].Lat, CoordArr[0].Lon, CoordArr[1].Lat, CoordArr[1].Lon, DistanceUnit),
DistanceUnit_Names[DistanceUnit]
]));
end;
procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
var
gpsObj: TGpsObj;
i: Integer;
rPt: TRealPoint;
item: TListItem;
begin
if ListView.Selected <> nil then begin
gpsObj := FList[ListView.Selected.Index];
ListView.Selected.Free;
FViewer.GpsItems.Clear(_CLICKED_POINTS_);
for i:=0 to ListView.Items.Count-1 do begin
item := ListView.Items[i];
if TryStrToGps(item.SubItems[2], rPt.Lon) and TryStrToGps(item.SubItems[1], rPt.Lat) then
begin
gpsObj := TGpsPoint.CreateFrom(rPt);
gpsObj.Name := item.SubItems[0];
FViewer.GPSItems.Add(gpsObj, _CLICKED_POINTS_);
end;
end;
end;
end;
procedure TGPSListViewer.BtnGoToPointClick(Sender: TObject);
var
gpsPt: TGpsPoint;
gpsObj: TGpsObj;
begin
if ListView.Selected <> nil then begin
gpsObj := FList[ListView.Selected.Index];
if gpsObj is TGpsPoint then begin
gpsPt := TGpsPoint(gpsObj);
if Assigned(FViewer) then FViewer.Center := gpsPt.RealPoint;
end;
end;
end;
procedure TGPSListViewer.BtnSavePtsClick(Sender: TObject);
var
i: Integer;
gpsPt: TGpsPoint;
gpsObj: TGpsObj;
L: TStrings;
s: String;
begin
if (OpenDialog.FileName <> '') and (SaveDialog.FileName = '') then
SaveDialog.FileName := OpenDialog.FileName;
if SaveDialog.FileName <> '' then
SaveDialog.InitialDir := ExtractFileDir(SaveDialog.FileName);
if not SaveDialog.Execute then exit;
L := TStringList.Create;
try
s := 'Index'#9'Name'#9'Longitude'#9'Latitude';
L.Add(s);
for i:=0 to FList.Count-1 do begin
gpsObj := FList[i];
if gpsObj is TGpsPoint then begin
gpsPt := TGpsPoint(gpsObj);
s := Format('%d'#9'%s'#9'%s'#9'%s', [
i, gpsPt.Name, LonToStr(gpsPt.Lon, true), LatToStr(gpsPt.Lat, true)
]);
L.Add(s);
end;
L.SaveToFile(SaveDialog.FileName);
end;
finally
L.Free;
end;
end;
procedure TGPSListViewer.BtnLoadTrackClick(Sender: TObject);
var
L: TStrings;
gpsTrack: TGpsTrack;
gpsPt: TGpsPoint;
sa: TStringArray;
lon, lat: Double;
i: Integer;
item: TListItem;
begin
if (SaveDialog.FileName <> '') and (OpenDialog.FileName = '') then
OpenDialog.FileName := SaveDialog.FileName;
if OpenDialog.FileName <> '' then
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.FileName);
if not OpenDialog.Execute then exit;
gpsTrack := TGpsTrack.Create;
L := TStringList.Create;
try
L.LoadFromFile(OpenDialog.FileName);
for i := 1 to L.Count - 1 do begin // i=1 --> skip header line
if L[i] = '' then Continue;
sa := L[i].Split(#9);
if TryStrToGps(sa[2], lon) and TryStrToGps(sa[3], lat) then begin
gpsPt := TGpsPoint.Create(lon, lat);
gpsPt.Name := sa[1];
gpsTrack.Points.Add(gpsPt);
end;
end;
FViewer.GPSItems.Add(gpsTrack, _TRACK_POINTS_);
FViewer.Center := gpsPt.RealPoint;
finally
L.Free;
end;
ListView.Items.BeginUpdate;
try
ListView.Items.Clear;
for i:=0 to gpsTrack.Points.Count - 1 do begin
gpsPt := gpsTrack.Points[i];
item := ListView.Items.Add;
item.SubItems.Add(gpsPt.Name);
item.SubItems.Add(LatToStr(gpsPt.Lat, true));
item.SubItems.Add(LonToStr(gpsPt.Lon, true));
end;
finally
ListView.Items.EndUpdate;
end;
end;
procedure TGPSListViewer.SetViewer(AValue: TMapView);
begin
if FViewer = AValue then
exit;
FViewer := AValue;
Populate;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -1,973 +0,0 @@
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Types, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, Spin, Grids, ExtDlgs,
mvGeoNames, mvMapViewer, mvTypes, mvGpsObj,
mvDrawingEngine, mvDE_RGBGraphics, mvDE_BGRA, mvDE_LCL,
mvDLEFPC, mvDLEWin, mvDLESynapse;
type
{ TMainForm }
TMainForm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
BtnSearch: TButton;
BtnGoTo: TButton;
BtnGPSPoints: TButton;
BtnSaveToFile: TButton;
BtnLoadGPXFile: TButton;
BtnPOITextFont: TButton;
BtnSelectPOIImage: TButton;
CbDoubleBuffer: TCheckBox;
CbDownloadEngine: TComboBox;
CbFoundLocations: TComboBox;
CbLocations: TComboBox;
CbProviders: TComboBox;
lblOpacity: TLabel;
OpenPictureDialog: TOpenPictureDialog;
rgDrawMode: TRadioGroup;
rbProxyData: TRadioButton;
rbSystemProxy: TRadioButton;
CbUseThreads: TCheckBox;
CbMouseCoords: TGroupBox;
CbDistanceUnits: TComboBox;
CbDebugTiles: TCheckBox;
CbDrawingEngine: TComboBox;
CbShowPOIImage: TCheckBox;
cbPOITextBgColor: TColorBox;
CbZoomToCursor: TCheckBox;
CbCyclic: TCheckBox;
CbPreviewTiles: TCheckBox;
clbBackColor: TColorButton;
edProxyHost: TEdit;
edProxyPassword: TEdit;
edProxyUserName: TEdit;
FontDialog: TFontDialog;
GbCenterCoords: TGroupBox;
gbProxy: TGroupBox;
GbScreenSize: TGroupBox;
GbSearch: TGroupBox;
GbGPS: TGroupBox;
InfoCenterLatitude: TLabel;
InfoViewportHeight: TLabel;
InfoCenterLongitude: TLabel;
InfoBtnGPSPoints: TLabel;
GPSPointInfo: TLabel;
InfoViewportWidth: TLabel;
Label1: TLabel;
Label2: TLabel;
LblPOITextBgColor: TLabel;
lblProxyHost: TLabel;
lblProxyPassword: TLabel;
lblProxyPort: TLabel;
lblProxyUserName: TLabel;
LblSelectLocation: TLabel;
LblCenterLatitude: TLabel;
LblViewportHeight: TLabel;
LblViewportWidth: TLabel;
LblPositionLongitude: TLabel;
LblPositionLatitude: TLabel;
InfoPositionLongitude: TLabel;
InfoPositionLatitude: TLabel;
LblCenterLongitude: TLabel;
LblProviders: TLabel;
LblZoom: TLabel;
MapView: TMapView;
GeoNames: TMVGeoNames;
BtnLoadMapProviders: TSpeedButton;
BtnSaveMapProviders: TSpeedButton;
OpenDialog: TOpenDialog;
PageControl: TPageControl;
PgData: TTabSheet;
PgConfig: TTabSheet;
rbNoProxy: TRadioButton;
seProxyPort: TSpinEdit;
pgLayers: TTabSheet;
sgLayers: TStringGrid;
tbOpacity: TTrackBar;
ZoomTrackBar: TTrackBar;
procedure BtnGoToClick(Sender: TObject);
procedure BtnLoadGPXFileClick(Sender: TObject);
procedure BtnSearchClick(Sender: TObject);
procedure BtnGPSPointsClick(Sender: TObject);
procedure BtnSaveToFileClick(Sender: TObject);
procedure BtnPOITextFontClick(Sender: TObject);
procedure BtnSelectPOIImageClick(Sender: TObject);
procedure CbDebugTilesChange(Sender: TObject);
procedure CbDownloadEngineChange(Sender: TObject);
procedure CbDrawingEngineChange(Sender: TObject);
procedure CbDoubleBufferChange(Sender: TObject);
procedure CbFoundLocationsDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
procedure cbPOITextBgColorChange(Sender: TObject);
procedure CbPreviewTilesChange(Sender: TObject);
procedure CbProvidersChange(Sender: TObject);
procedure CbShowPOIImageChange(Sender: TObject);
procedure CbUseThreadsChange(Sender: TObject);
procedure CbDistanceUnitsChange(Sender: TObject);
procedure CbZoomToCursorChange(Sender: TObject);
procedure CbCyclicChange(Sender: TObject);
procedure clbBackColorColorChanged(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GeoNamesNameFound(const AName: string; const ADescr: String;
const ALoc: TRealPoint);
procedure MapViewChange(Sender: TObject);
procedure MapViewDrawGpsPoint(Sender: TObject;
ADrawer: TMvCustomDrawingEngine; APoint: TGpsPoint);
procedure MapViewMouseLeave(Sender: TObject);
procedure MapViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure MapViewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MapViewZoomChange(Sender: TObject);
procedure BtnLoadMapProvidersClick(Sender: TObject);
procedure BtnSaveMapProvidersClick(Sender: TObject);
procedure rbProxyChange(Sender: TObject);
procedure rgDrawModeSelectionChanged(Sender: TObject);
procedure sgLayersCheckboxToggled(Sender: TObject; aCol, aRow: Integer;
aState: TCheckboxState);
procedure sgLayersEditingDone(Sender: TObject);
procedure sgLayersSelection(Sender: TObject; aCol, aRow: Integer);
procedure tbOpacityChange(Sender: TObject);
procedure UpdateLayers;
procedure ZoomTrackBarChange(Sender: TObject);
private
FRGBGraphicsDrawingEngine: TMvRGBGraphicsDrawingEngine;
FBGRADrawingEngine: TMvBGRADrawingEngine;
FLCLDrawingEngine: TMvLCLDrawingEngine;
FSynapseDownloadEngine: TMvDESynapse;
FFpHttpClientDownloadEngine: TMvDEFPC;
{$IFDEF MSWINDOWS}
FWinDownloadEngine: TMvDEWin;
{$ENDIF}
POIImage: TCustomBitmap;
procedure ClearFoundLocations;
procedure UpdateCoords(X, Y: Integer);
procedure UpdateDownloadEngineProxy;
procedure UpdateDropdownWidth(ACombobox: TCombobox);
procedure UpdateLocationHistory(ALocation: String);
procedure UpdateViewportSize;
public
procedure ReadFromIni;
procedure WriteToIni;
end;
var
MainForm: TMainForm;
implementation
{$R *.lfm}
uses
LCLType, IniFiles, Math, FPCanvas, FPImage, GraphType,
mvEngine, mvGPX,
globals, gpslistform;
type
TLocationParam = class
Descr: String;
Loc: TRealPoint;
end;
const
MAX_LOCATIONS_HISTORY = 50;
MAP_PROVIDER_FILENAME = 'map-providers.xml';
USE_DMS = true;
_TILELAYERS_ID_ = 42;
var
PointFormatSettings: TFormatsettings;
TileLayer: array[0..9] of TGPSTileLayer;
function CalcIniName: String;
begin
Result := ChangeFileExt(Application.ExeName, '.ini');
end;
{ TMainForm }
procedure TMainForm.BtnLoadMapProvidersClick(Sender: TObject);
var
fn: String;
msg: String;
begin
fn := Application.Location + MAP_PROVIDER_FILENAME;
if FileExists(fn) then begin
if MapView.Engine.ReadProvidersFromXML(fn, msg) then begin
MapView.GetMapProviders(CbProviders.Items);
CbProviders.ItemIndex := 0;
MapView.MapProvider := CbProviders.Text;
sgLayers.Columns[1].PickList.Assign(CbProviders.Items);
end else
ShowMessage(msg);
end;
end;
procedure TMainForm.BtnSaveMapProvidersClick(Sender: TObject);
begin
MapView.Engine.WriteProvidersToXML(Application.Location + MAP_PROVIDER_FILENAME);
end;
procedure TMainForm.rbProxyChange(Sender: TObject);
begin
UpdateDownloadEngineProxy;
end;
procedure TMainForm.rgDrawModeSelectionChanged(Sender: TObject);
begin
TileLayer[Pred(sgLayers.Row)].DrawMode := TItemDrawMode(rgDrawMode.ItemIndex);
MapView.Redraw;
end;
procedure TMainForm.sgLayersCheckboxToggled(Sender: TObject; aCol,
aRow: Integer; aState: TCheckboxState);
begin
if TileLayer[Pred(sgLayers.Row)].MapProvider.IsEmpty then
Exit;
TileLayer[Pred(sgLayers.Row)].Visible := (aState = cbChecked);
MapView.Redraw;
end;
procedure TMainForm.sgLayersEditingDone(Sender: TObject);
var
S: String;
begin
if sgLayers.Col <> 2 then
Exit;
S := sgLayers.Cells[sgLayers.Col, sgLayers.Row];
TileLayer[Pred(sgLayers.Row)].MapProvider := S;
sgLayers.Cells[sgLayers.Col, sgLayers.Row] := S;
MapView.Redraw;
end;
procedure TMainForm.sgLayersSelection(Sender: TObject; aCol, aRow: Integer);
begin
rgDrawMode.ItemIndex := Ord(TileLayer[Pred(ARow)].DrawMode);
tbOpacity.Position := Round(TileLayer[Pred(ARow)].Opacity * 100);
end;
procedure TMainForm.tbOpacityChange(Sender: TObject);
begin
TileLayer[Pred(sgLayers.Row)].Opacity := tbOpacity.Position / 100;
MapView.Redraw;
end;
procedure TMainForm.UpdateLayers;
var
TL: TGPSTileLayer;
begin
// Notify tile layers for drawing engine change, it must be done implicitly
// but there is no other mechanism for now
for TL in TileLayer do
TL.ParentViewChanged;
end;
procedure TMainForm.BtnSearchClick(Sender: TObject);
begin
ClearFoundLocations;
GeoNames.Search(CbLocations.Text, MapView.DownloadEngine);
UpdateDropdownWidth(CbFoundLocations);
UpdateLocationHistory(CbLocations.Text);
if CbFoundLocations.Items.Count > 0 then CbFoundLocations.ItemIndex := 0;
end;
procedure TMainForm.BtnGPSPointsClick(Sender: TObject);
var
F: TGpsListViewer;
begin
F := TGpsListViewer.Create(nil);
try
F.MapViewer := MapView;
F.ShowModal;
finally
F.Free;
end;
end;
procedure TMainForm.BtnGoToClick(Sender: TObject);
var
s: String;
P: TLocationParam;
begin
if CbFoundLocations.ItemIndex = -1 then
exit;
// Extract parameters of found locations. We need that to get the coordinates.
s := CbFoundLocations.Items.Strings[CbFoundLocations.ItemIndex];
P := TLocationParam(CbFoundLocations.Items.Objects[CbFoundLocations.ItemIndex]);
if P = nil then
exit;
CbFoundLocations.Text := s;
// Show location in center of mapview
MapView.Zoom := 12;
MapView.Center := P.Loc;
MapView.Invalidate;
end;
procedure TMainForm.BtnLoadGPXFileClick(Sender: TObject);
var
reader: TGpxReader;
b: TRealArea;
begin
if OpenDialog.FileName <> '' then
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.Filename);
if OpenDialog.Execute then begin
reader := TGpxReader.Create;
try
reader.LoadFromFile(OpenDialog.FileName, MapView.GPSItems, b);
MapView.Engine.ZoomOnArea(b);
MapViewZoomChange(nil);
finally
reader.Free;
end;
end;
end;
procedure TMainForm.BtnSaveToFileClick(Sender: TObject);
begin
MapView.SaveToFile(TPortableNetworkGraphic, 'mapview.png');
ShowMessage('Map saved to "mapview.png".');
end;
procedure TMainForm.BtnPOITextFontClick(Sender: TObject);
begin
FontDialog.Font.Assign(MapView.Font);
if FontDialog.Execute then
MapView.Font.Assign(FontDialog.Font);
end;
procedure TMainForm.BtnSelectPOIImageClick(Sender: TObject);
begin
OpenPictureDialog.Filter := 'PNG files|*.png|BMP files|*.bmp';
OpenPictureDialog.DefaultExt := '.png';
if OpenPictureDialog.Execute then
begin
POIImage.LoadFromFile(OpenPictureDialog.FileName);
MapView.POIImage.Assign(POIImage);
end;
end;
procedure TMainForm.CbDebugTilesChange(Sender: TObject);
begin
MapView.DebugTiles := CbDebugTiles.Checked;
MapView.Invalidate;
end;
procedure TMainForm.CbDownloadEngineChange(Sender: TObject);
begin
case CbDownloadEngine.ItemIndex of
0: MapView.DownloadEngine := nil;
1: begin
if FSynapseDownloadEngine = nil then
FSynapseDownloadEngine := TMvDESynapse.Create(self);
MapView.DownloadEngine := FSynapseDownloadEngine;
end;
2: begin
if FFpHttpClientDownloadEngine = nil then
FFpHttpClientDownloadEngine := TMvDEFPC.Create(self);
MapView.DownloadEngine := FFpHttpClientDownloadEngine;
end;
3: begin
{$IFDEF MSWINDOWS}
if FWinDownloadEngine = nil then
FWinDownloadEngine := TMvDEWin.Create(Self);
MapView.DownloadEngine := FWinDownloadEngine;
{$ELSE}
ShowMessage('WinInet download engine can only be used in Windows.');
{$ENDIF}
end;
end;
UpdateDownloadEngineProxy;
end;
procedure TMainForm.CbDrawingEngineChange(Sender: TObject);
begin
case CbDrawingEngine.ItemIndex of
0: MapView.DrawingEngine := nil;
1: begin
if FRGBGraphicsDrawingEngine = nil then
FRGBGraphicsDrawingEngine := TMvRGBGraphicsDrawingEngine.Create(self);
MapView.DrawingEngine := FRGBGraphicsDrawingEngine;
end;
2: begin
if FBGRADrawingEngine = nil then
FBGRADrawingEngine := TMvBGRADrawingEngine.Create(self);
MapView.DrawingEngine := FBGRADrawingEngine;
end;
3: begin
if FLCLDrawingEngine = nil then
FLCLDrawingEngine := TMvLCLDrawingEngine.Create(self);
MapView.DrawingEngine := FLCLDrawingEngine;
end;
end;
UpdateLayers;
end;
procedure TMainForm.CbDoubleBufferChange(Sender: TObject);
begin
MapView.DoubleBuffered := CbDoubleBuffer.Checked;
end;
procedure TMainForm.CbFoundLocationsDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
var
s: String;
P: TLocationParam;
combo: TCombobox;
x, y: Integer;
begin
combo := TCombobox(Control);
if (State * [odSelected, odFocused] <> []) then begin
combo.Canvas.Brush.Color := clHighlight;
combo.Canvas.Font.Color := clHighlightText;
end else begin
combo.Canvas.Brush.Color := clWindow;
combo.Canvas.Font.Color := clWindowText;
end;
combo.Canvas.FillRect(ARect);
combo.Canvas.Brush.Style := bsClear;
s := combo.Items.Strings[Index];
P := TLocationParam(combo.Items.Objects[Index]);
x := ARect.Left + 2;
y := ARect.Top + 2;
combo.Canvas.Font.Style := [fsBold];
combo.Canvas.TextOut(x, y, s);
inc(y, combo.Canvas.TextHeight('Tg'));
combo.Canvas.Font.Style := [];
combo.Canvas.TextOut(x, y, P.Descr);
end;
procedure TMainForm.cbPOITextBgColorChange(Sender: TObject);
begin
MapView.POITextBgColor := cbPOITextBgColor.Selected;
end;
procedure TMainForm.CbPreviewTilesChange(Sender: TObject);
begin
MapView.DrawPreviewTiles := CbPreviewTiles.Checked;
end;
procedure TMainForm.CbProvidersChange(Sender: TObject);
begin
MapView.MapProvider := CbProviders.Text;
end;
procedure TMainForm.CbShowPOIImageChange(Sender: TObject);
begin
if CbShowPOIImage.Checked then
MapView.POIImage := POIImage
else
MapView.POIImage.Clear;
BtnSelectPOIImage.Enabled := CbShowPOIImage.Checked;
MapView.Invalidate;
end;
procedure TMainForm.CbUseThreadsChange(Sender: TObject);
begin
MapView.UseThreads := CbUseThreads.Checked;
UpdateLayers;
end;
procedure TMainForm.CbDistanceUnitsChange(Sender: TObject);
begin
DistanceUnit := TDistanceUnits(CbDistanceUnits.ItemIndex);
UpdateViewPortSize;
end;
procedure TMainForm.CbZoomToCursorChange(Sender: TObject);
begin
MapView.ZoomToCursor := CbZoomToCursor.Checked;
end;
procedure TMainForm.CbCyclicChange(Sender: TObject);
begin
MapView.Cyclic := CbCyclic.Checked;
UpdateLayers;
end;
procedure TMainForm.clbBackColorColorChanged(Sender: TObject);
begin
MapView.InactiveColor := clbBackColor.ButtonColor;
end;
procedure TMainForm.ClearFoundLocations;
var
i: Integer;
P: TLocationParam;
begin
for i:=0 to CbFoundLocations.Items.Count-1 do begin
P := TLocationParam(CbFoundLocations.Items.Objects[i]);
P.Free;
end;
CbFoundLocations.Items.Clear;
end;
procedure TMainForm.FormCreate(Sender: TObject);
var
fn: String;
I: Integer;
begin
cInputQueryEditSizePercents := 0;
fn := Application.Location + 'mapmarker.png';
if not FileExists(fn) then
MessageDlg('Copy the file "mapmarker.png" from the source folder to the folder with the executable.',
mtError, [mbOK], 0)
else
begin
// FMapMarker := CreateMapMarker(32, clRed, clBlack);
POIImage := TPortableNetworkGraphic.Create;
POIImage.PixelFormat := pf32bit;
POIImage.LoadFromFile(fn);
end;
MapView.GetMapProviders(CbProviders.Items);
sgLayers.Columns[1].PickList.Assign(CbProviders.Items);
CbProviders.ItemIndex := CbProviders.Items.IndexOf(MapView.MapProvider);
MapView.DoubleBuffered := true;
MapView.Zoom := 1;
CbZoomToCursor.Checked := MapView.ZoomToCursor;
CbUseThreads.Checked := MapView.UseThreads;
CbDoubleBuffer.Checked := MapView.DoubleBuffered;
CbPOITextBgColor.Selected := MapView.POITextBgColor;
CbPOITextBgColor.ItemHeight := CbProviders.ItemHeight + 2;
clbBackColor.ButtonColor := MapView.InactiveColor;
InfoPositionLongitude.Caption := '';
InfoPositionLatitude.Caption := '';
InfoCenterLongitude.Caption := '';
InfoCenterLatitude.Caption := '';
InfoViewportWidth.Caption := '';
InfoViewportHeight.Caption := '';
GPSPointInfo.Caption := '';
for I := 0 to High(TileLayer) do
begin
TileLayer[I] := TGPSTileLayer.Create;
with TileLayer[I] do
begin
Visible := False;
UseThreads := MapView.UseThreads;
DrawMode := idmUseOpacity;
Opacity := 0.25;
case I of
0: MapProvider := 'Google Satellite Only';
1: MapProvider := 'Google Terrain';
2: MapProvider := 'Maps For Free';
otherwise
MapProvider := '';
end;
end;
sgLayers.Cells[1, I + 1] := TileLayer[I].Visible.ToString;
sgLayers.Cells[2, I + 1] := TileLayer[I].MapProvider;
MapView.GPSLayer[I].Add(TileLayer[I], _TILELAYERS_ID_);
end;
ReadFromIni;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
var
I: Integer;
begin
WriteToIni;
ClearFoundLocations;
FreeAndNil(POIImage);
FreeAndNil(FRGBGraphicsDrawingEngine);
FreeAndNil(FBGRADrawingEngine);
FreeAndNil(FSynapseDownloadEngine);
FreeAndNil(FFpHttpClientDownloadEngine);
{$IFDEF MSWINDOWS}
FreeAndNil(FWinDownloadEngine);
{$ENDIF}
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
MapView.Active := true;
end;
procedure TMainForm.GeoNamesNameFound(const AName: string;
const ADescr: String; const ALoc: TRealPoint);
var
P: TLocationParam;
begin
P := TLocationParam.Create;
P.Descr := ADescr;
P.Loc := ALoc;
CbFoundLocations.Items.AddObject(AName, P);
end;
procedure TMainForm.MapViewChange(Sender: TObject);
begin
UpdateViewportSize;
end;
procedure TMainForm.MapViewDrawGpsPoint(Sender: TObject;
ADrawer: TMvCustomDrawingEngine; APoint: TGpsPoint);
const
R = 5;
var
P: TPoint;
ext: TSize;
begin
// Screen coordinates of the GPS point
P := TMapView(Sender).LatLonToScreen(APoint.RealPoint);
// Draw the GPS point with MapMarker bitmap
{
if CbShowPOIImage.Checked and not MapView.POIImage.Empty then begin
ADrawer.DrawBitmap(P.X - MapView.POIImage.Width div 2, P.Y - MapView.POIImage.Height, MapView.POIImage, true);
end else begin
}
// Draw the GPS point as a circle
ADrawer.BrushColor := clRed;
ADrawer.BrushStyle := bsSolid;
ADrawer.Ellipse(P.X - R, P.Y - R, P.X + R, P.Y + R);
P.Y := P.Y + R;
//end;
{
// Draw the caption of the GPS point
ext := ADrawer.TextExtent(APoint.Name);
ADrawer.BrushColor := clWhite;
ADrawer.BrushStyle := bsClear;
ADrawer.TextOut(P.X - ext.CX div 2, P.Y + 5, APoint.Name);
}
end;
procedure TMainForm.MapViewMouseLeave(Sender: TObject);
begin
UpdateCoords(MaxInt, MaxInt);
end;
procedure TMainForm.MapViewMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
const
DELTA = 3;
var
rArea: TRealArea;
gpsList: TGpsObjList;
L: TStrings;
i: Integer;
begin
UpdateCoords(X, Y);
rArea.TopLeft := MapView.ScreenToLatLon(Point(X-DELTA, Y-DELTA));
rArea.BottomRight := MapView.ScreenToLatLon(Point(X+DELTA, Y+DELTA));
gpsList := MapView.GpsItems.GetObjectsInArea(rArea);
try
if gpsList.Count > 0 then begin
L := TStringList.Create;
try
for i:=0 to gpsList.Count-1 do
if gpsList[i] is TGpsPoint then
with TGpsPoint(gpsList[i]) do
L.Add(Format('%s' + LineEnding + ' %s / %s', [
Name, LatToStr(Lat, USE_DMS), LonToStr(Lon, USE_DMS)
]));
GPSPointInfo.Caption := L.Text;
finally
L.Free;
end;
end else
GPSPointInfo.Caption := '';
finally
gpsList.Free;
end;
end;
procedure TMainForm.MapViewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
rPt: TRealPoint;
gpsPt: TGpsPoint;
gpsName: String;
begin
if (Button = mbRight) then begin
if not InputQuery('Name of GPS location', 'Please enter name', gpsName) then
exit;
rPt := MapView.ScreenToLatLon(Point(X, Y));
gpsPt := TGpsPoint.CreateFrom(rPt);
gpsPt.Name := gpsName;
MapView.GpsItems.Add(gpsPt, _CLICKED_POINTS_);
end;
end;
procedure TMainForm.MapViewZoomChange(Sender: TObject);
begin
ZoomTrackbar.Position := MapView.Zoom;
end;
procedure TMainForm.ReadFromIni;
var
ini: TCustomIniFile;
List: TStringList;
L, T, W, H: Integer;
R: TRect;
i: Integer;
s: String;
pt: TRealPoint;
du: TDistanceUnits;
begin
ini := TMemIniFile.Create(CalcIniName);
try
HERE_AppID := ini.ReadString('HERE', 'APP_ID', '');
HERE_AppCode := ini.ReadString('HERE', 'APP_CODE', '');
OpenWeatherMap_ApiKey := ini.ReadString('OpenWeatherMap', 'API_Key', '');
ThunderForest_ApiKey := ini.ReadString('ThunderForest', 'API_Key', '');
if ((HERE_AppID <> '') and (HERE_AppCode <> '')) or
(OpenWeatherMap_ApiKey <> '') or
(ThunderForest_ApiKey <> '') then
begin
MapView.Engine.ClearMapProviders;
MapView.Engine.RegisterProviders;
MapView.GetMapProviders(CbProviders.Items);
sgLayers.Columns[1].PickList.Assign(CbProviders.Items);
end;
R := Screen.DesktopRect;
L := ini.ReadInteger('MainForm', 'Left', Left);
T := ini.ReadInteger('MainForm', 'Top', Top);
W := ini.ReadInteger('MainForm', 'Width', Width);
H := ini.ReadInteger('MainForm', 'Height', Height);
if L + W > R.Right then L := R.Right - W;
if L < R.Left then L := R.Left;
if T + H > R.Bottom then T := R.Bottom - H;
if T < R.Top then T := R.Top;
SetBounds(L, T, W, H);
s := ini.ReadString('MapView', 'Provider', MapView.MapProvider);
if CbProviders.Items.IndexOf(s) = -1 then begin
MessageDlg('Map provider "' + s + '" not found.', mtError, [mbOK], 0);
s := CbProviders.Items[0];
end;
MapView.MapProvider := s;
CbProviders.Text := MapView.MapProvider;
MapView.Zoom := ini.ReadInteger('MapView', 'Zoom', MapView.Zoom);
pt.Lon := StrToFloatDef(ini.ReadString('MapView', 'Center.Longitude', ''), 0.0, PointFormatSettings);
pt.Lat := StrToFloatDef(ini.ReadString('MapView', 'Center.Latitude', ''), 0.0, PointFormatSettings);
MapView.Center := pt;
MapView.InactiveColor := ini.ReadInteger('MapView', 'MapBkgrColor', MapView.InactiveColor);
clbBackColor.ButtonColor := MapView.InactiveColor;
s := ini.ReadString('MapView', 'DistanceUnits', '');
if s <> '' then begin
for du in TDistanceUnits do
if DistanceUnit_Names[du] = s then begin
DistanceUnit := du;
CbDistanceUnits.ItemIndex := ord(du);
break;
end;
end;
List := TStringList.Create;
try
ini.ReadSection('Locations', List);
for i:=0 to List.Count-1 do begin
s := ini.ReadString('Locations', List[i], '');
if s <> '' then
CbLocations.Items.Add(s);
end;
finally
List.Free;
end;
i := ini.ReadInteger('Proxy', 'UseProxy', 0);
case i of
0: rbNoProxy.Checked := true;
1: rbSystemProxy.Checked := true;
2: rbProxyData.Checked := true;
end;
edProxyHost.Text := ini.ReadString('Proxy', 'ProxyHost', edProxyHost.Text);
seProxyPort.Value := ini.ReadInteger('Proxy', 'ProxyPort', seProxyPort.Value);
edProxyUserName.Text := ini.ReadString('Proxy', 'ProxyName', edProxyUserName.Text);
edProxyPassword.Text := ini.ReadString('Proxy', 'ProxyPassword', edProxyPassword.Text);
UpdateDownloadEngineProxy;
finally
ini.Free;
end;
end;
procedure TMainForm.UpdateCoords(X, Y: Integer);
var
rPt: TRealPoint;
begin
rPt := MapView.Center;
InfoCenterLongitude.Caption := LonToStr(rPt.Lon, USE_DMS);
InfoCenterLatitude.Caption := LatToStr(rPt.Lat, USE_DMS);
if (X <> MaxInt) and (Y <> MaxInt) then begin
rPt := MapView.ScreenToLatLon(Point(X, Y));
InfoPositionLongitude.Caption := LonToStr(rPt.Lon, USE_DMS);
InfoPositionLatitude.Caption := LatToStr(rPt.Lat, USE_DMS);
end else begin
InfoPositionLongitude.Caption := '-';
InfoPositionLatitude.Caption := '-';
end;
end;
procedure TMainForm.UpdateDownloadEngineProxy;
begin
if MapView.DownloadEngine.HasProxySupport then
begin
MapView.DownloadEngine.SetProxy(
rbSystemProxy.Checked, rbProxyData.Checked,
edProxyHost.Name, seProxyPort.Value, edProxyUserName.Text, edProxyPassword.Text
);
rbSystemProxy.Enabled := MapView.DownloadEngine.SupportsSystemProxy;
lblProxyHost.Enabled := rbProxyData.Checked;
edProxyHost.Enabled := rbProxyData.Checked;
lblProxyPort.Enabled := rbProxyData.Checked;
seProxyPort.Enabled := rbProxyData.Checked;
lblProxyUserName.Enabled := rbProxyData.Checked;
edProxyUserName.Enabled := rbProxyData.Checked;
lblProxyPassword.Enabled := rbProxyData.Checked;
edProxyPassword.Enabled := rbProxyData.Checked;
end;
end;
procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox);
var
cnv: TControlCanvas;
i, w: Integer;
s: String;
P: TLocationParam;
begin
w := 0;
cnv := TControlCanvas.Create;
try
cnv.Control := ACombobox;
cnv.Font.Assign(ACombobox.Font);
for i:=0 to ACombobox.Items.Count-1 do begin
cnv.Font.Style := [fsBold];
s := ACombobox.Items.Strings[i];
w := Max(w, cnv.TextWidth(s));
P := TLocationParam(ACombobox.Items.Objects[i]);
cnv.Font.Style := [];
w := Max(w, cnv.TextWidth(P.Descr));
end;
ACombobox.ItemWidth := w + 16;
ACombobox.ItemHeight := 2 * cnv.TextHeight('Tg') + 6;
finally
cnv.Free;
end;
end;
procedure TMainForm.UpdateLocationHistory(ALocation: String);
var
idx: Integer;
begin
idx := CbLocations.Items.IndexOf(ALocation);
if idx <> -1 then
CbLocations.Items.Delete(idx);
CbLocations.Items.Insert(0, ALocation);
while CbLocations.Items.Count > MAX_LOCATIONS_HISTORY do
CbLocations.Items.Delete(Cblocations.items.Count-1);
CbLocations.Text := ALocation;
end;
procedure TMainForm.UpdateViewportSize;
begin
InfoViewportWidth.Caption := Format('%.2n %s', [
CalcGeoDistance(
MapView.GetVisibleArea.TopLeft.Lat,
MapView.GetVisibleArea.TopLeft.Lon,
MapView.GetVisibleArea.TopLeft.Lat,
MapView.GetVisibleArea.BottomRight.Lon,
DistanceUnit
),
DistanceUnit_Names[DistanceUnit]
]);
InfoViewportHeight.Caption := Format('%.2n %s', [
CalcGeoDistance(
MapView.GetVisibleArea.TopLeft.Lat,
MapView.GetVisibleArea.TopLeft.Lon,
MapView.GetVisibleArea.BottomRight.Lat,
MapView.GetVisibleArea.TopLeft.Lon,
DistanceUnit
),
DistanceUnit_Names[DistanceUnit]
]);
end;
procedure TMainForm.WriteToIni;
var
ini: TCustomIniFile;
L: TStringList;
i: Integer;
begin
ini := TMemIniFile.Create(CalcIniName);
try
ini.WriteInteger('MainForm', 'Left', Left);
ini.WriteInteger('MainForm', 'Top', Top);
ini.WriteInteger('MainForm', 'Width', Width);
ini.WriteInteger('MainForm', 'Height', Height);
ini.WriteString('MapView', 'Provider', MapView.MapProvider);
ini.WriteInteger('MapView', 'Zoom', MapView.Zoom);
ini.WriteString('MapView', 'Center.Longitude', FloatToStr(MapView.Center.Lon, PointFormatSettings));
ini.WriteString('MapView', 'Center.Latitude', FloatToStr(MapView.Center.Lat, PointFormatSettings));
ini.WriteInteger('MapView', 'MapBkgrColor', MapView.InactiveColor);
ini.WriteString('MapView', 'DistanceUnits', DistanceUnit_Names[DistanceUnit]);
if HERE_AppID <> '' then
ini.WriteString('HERE', 'APP_ID', HERE_AppID);
if HERE_AppCode <> '' then
ini.WriteString('HERE', 'APP_CODE', HERE_AppCode);
if OpenWeatherMap_ApiKey <> '' then
ini.WriteString('OpenWeatherMap', 'API_Key', OpenWeatherMap_ApiKey);
if ThunderForest_ApiKey <> '' then
ini.WriteString('ThunderForest', 'API_Key', ThunderForest_ApiKey);
ini.EraseSection('Locations');
for i := 0 to CbLocations.Items.Count-1 do
ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]);
ini.EraseSection('Proxy');
if rbSystemProxy.Checked then i := 1
else if rbProxyData.Checked then i := 2
else i := 0;
ini.WriteInteger('Proxy', 'UseProxy', i);
ini.WriteString('Proxy', 'ProxyHost', edProxyHost.Text);
ini.WriteInteger('Proxy', 'ProxyPort', seProxyPort.Value);
ini.WriteString('Proxy', 'ProxyName', edProxyUserName.Text);
ini.WriteString('Proxy', 'ProxyPassword', edProxyPassword.Text);
finally
ini.Free;
end;
end;
procedure TMainForm.ZoomTrackBarChange(Sender: TObject);
begin
MapView.Zoom := ZoomTrackBar.Position;
LblZoom.Caption := Format('Zoom (%d):', [ZoomTrackbar.Position]);
end;
initialization
PointFormatSettings.DecimalSeparator := '.';
end.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<Title Value="mapviewer_demo_with_addons"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
</General>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages Count="5">
<Item1>
<PackageName Value="lazMapViewer_Synapse"/>
</Item1>
<Item2>
<PackageName Value="lazmapviewer_bgra"/>
</Item2>
<Item3>
<PackageName Value="lazmapviewer_rgbgraphics"/>
</Item3>
<Item4>
<PackageName Value="lazMapViewerPkg"/>
</Item4>
<Item5>
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="4">
<Unit0>
<Filename Value="mapviewer_demo_with_addons.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MapViewer_Demo_with_AddOns"/>
</Unit0>
<Unit1>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
</Unit1>
<Unit2>
<Filename Value="gpslistform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="GPSListViewer"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit2>
<Unit3>
<Filename Value="globals.pas"/>
<IsPartOfProject Value="True"/>
</Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="bin\$(TargetCPU)-$(TargetOS)\mapviewer_demo_with_addons"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="4">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
<Item4>
<Name Value="EHTTPClient"/>
</Item4>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -1,20 +0,0 @@
program MapViewer_Demo_with_AddOns;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}cthreads,{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Main, gpslistform, globals;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TGPSListViewer, GPSListViewer);
Application.Run;
end.

View File

@ -1,5 +0,0 @@
{ "MapViewer_FullDemo_with_AddOns" : {
"Category" : "ThirdParty",
"Keywords" : ["TMapView", "geography", "earth", "maps", "GPS", "longitude", "latitude", "gpx", "bgrabitmap", "rgbgraphics", "synapse"],
"Description" : "Similar to the other \"fulldemo\" project, this application gives an overview of all features available in the LazMapViewer package: \n- zoomable/draggable view of the maps\n- selection of map provider\n- searching of geo locations\n- adding markers\n- displaying gpx track files\n\nAdditionally, the project allows also to\n- select a drawing engine (internal, rgbagraphics, bgrabitmap)\n- select a download engine (internal, synapse)\n\nRequires installation of the lazmapviewer_rgbgraphics, lazmapviewer_bgra and lazmapviewer_synapse packages which, themselves, depend on other packages (lazmapviewer_rgbgraphics --> lazrgbgraphics; lazmapviewer_bgra --> bgrabitmappack; lazmapviewer_synapse --> laz_synapse)."}
}