LazMapViewer: Center gpx track after loading.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6920 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-05-17 16:52:19 +00:00
parent a71b0da7de
commit e3105224c0
3 changed files with 27 additions and 15 deletions

View File

@ -195,22 +195,20 @@ end;
procedure TMainForm.BtnLoadGPXFileClick(Sender: TObject);
var
reader: TGpxReader;
pt: TGpsPoint;
item: TGpsObj;
b: TRealArea;
pt: TRealPoint;
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);
reader.LoadFromFile(OpenDialog.FileName, MapView.GPSItems, b);
item := MapView.GPSItems.Items[MapView.GPSItems.Count-1];
if item is TGpsPoint then
pt := TGpsPoint(item)
else
if item is TGpsTrack then
pt := TGpsTrack(item).Points[0];
MapView.Center := pt.RealPoint;
pt.Lon := (b.TopLeft.Lon + b.BottomRight.Lon) * 0.5;
pt.Lat := (b.TopLeft.Lat + b.BottomRight.Lat) * 0.5;
MapView.Center := pt;
finally
reader.Free;
end;