LazMapViewer: Zoom to bounds of points in loaded gpx file.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6921 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-05-17 20:28:46 +00:00
parent e3105224c0
commit 1aaebb2780
2 changed files with 3 additions and 7 deletions

View File

@ -195,9 +195,7 @@ end;
procedure TMainForm.BtnLoadGPXFileClick(Sender: TObject); procedure TMainForm.BtnLoadGPXFileClick(Sender: TObject);
var var
reader: TGpxReader; reader: TGpxReader;
item: TGpsObj;
b: TRealArea; b: TRealArea;
pt: TRealPoint;
begin begin
if OpenDialog.FileName <> '' then if OpenDialog.FileName <> '' then
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.Filename); OpenDialog.InitialDir := ExtractFileDir(OpenDialog.Filename);
@ -205,10 +203,8 @@ begin
reader := TGpxReader.Create; reader := TGpxReader.Create;
try try
reader.LoadFromFile(OpenDialog.FileName, MapView.GPSItems, b); reader.LoadFromFile(OpenDialog.FileName, MapView.GPSItems, b);
item := MapView.GPSItems.Items[MapView.GPSItems.Count-1]; MapView.Engine.ZoomOnArea(b);
pt.Lon := (b.TopLeft.Lon + b.BottomRight.Lon) * 0.5; MapViewZoomChange(nil);
pt.Lat := (b.TopLeft.Lat + b.BottomRight.Lat) * 0.5;
MapView.Center := pt;
finally finally
reader.Free; reader.Free;
end; end;

View File

@ -1142,7 +1142,7 @@ begin
tmpWin := MapWin; tmpWin := MapWin;
tmpWin.Center.Lon := (aArea.TopLeft.Lon + aArea.BottomRight.Lon) / 2; tmpWin.Center.Lon := (aArea.TopLeft.Lon + aArea.BottomRight.Lon) / 2;
tmpWin.Center.Lat := (aArea.TopLeft.Lat + aArea.BottomRight.Lat) / 2; tmpWin.Center.Lat := (aArea.TopLeft.Lat + aArea.BottomRight.Lat) / 2;
tmpWin.Zoom := 15; tmpWin.Zoom := 18;
TopLeft.X := 0; TopLeft.X := 0;
TopLeft.Y := 0; TopLeft.Y := 0;
BottomRight.X := tmpWin.Width; BottomRight.X := tmpWin.Width;