lazmapviewer: Add display of mouse-over gps-point-infos.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6795 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
205588f98c
commit
da045c8ab0
@ -66,7 +66,6 @@
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
|
@ -17,6 +17,9 @@ object GPSListViewer: TGPSListViewer
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Right = 6
|
||||
Columns = <
|
||||
item
|
||||
Caption = 'ID'
|
||||
end
|
||||
item
|
||||
Caption = 'Name'
|
||||
Width = 150
|
||||
@ -29,12 +32,8 @@ object GPSListViewer: TGPSListViewer
|
||||
Caption = 'Longitude'
|
||||
Width = 150
|
||||
end>
|
||||
ReadOnly = True
|
||||
RowSelect = True
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
OnDblClick = ListViewDblClick
|
||||
OnSelectItem = ListViewSelectItem
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
@ -197,55 +196,5 @@ object GPSListViewer: TGPSListViewer
|
||||
OnClick = BtnCloseClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object BtnClearAll: TBitBtn
|
||||
AnchorSideLeft.Control = BtnDeletePoint
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 234
|
||||
Height = 26
|
||||
Top = 6
|
||||
Width = 88
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Clear all'
|
||||
Glyph.Data = {
|
||||
36040000424D3604000000000000360000002800000010000000100000000100
|
||||
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000
|
||||
0000000000000000003300000033000000000000000000000000000000000000
|
||||
00000000000000000033000000330000000000000000FFFFFF00FFFFFF000000
|
||||
0000000000333040C4FF3040C4FF000000330000000000000000000000000000
|
||||
0000000000333040C4FF3040C4FF0000003300000000FFFFFF00FFFFFF000000
|
||||
00333040C4FF6C7EFCFF6C7EFCFF3040C4FF0000003300000000000000000000
|
||||
00333040C4FF6C7EFCFF6C7EFCFF3040C4FF00000033FFFFFF00FFFFFF003040
|
||||
C4FF7182FAFF596EF9FF596EF9FF7182FAFF3040C4FF00000033000000333040
|
||||
C4FF7182FAFF596EF9FF596EF9FF7182FAFF3040C4FFFFFFFF00FFFFFF003040
|
||||
C4FF7687F8FF5469F7FF5469F7FF5469F7FF7687F8FF3040C4FF3040C4FF7687
|
||||
F8FF5469F7FF5469F7FF5469F7FF7687F8FF3040C4FFFFFFFF00FFFFFF000000
|
||||
00003040C4FF7B8CF7FF4F65F5FF4F65F5FF4F65F5FF7B8CF7FF7B8CF7FF4F65
|
||||
F5FF4F65F5FF4F65F5FF7B8CF7FF3040C4FF00000000FFFFFF00FFFFFF000000
|
||||
0000000000003040C4FF8291F6FF4B61F3FF4B61F3FF4B61F3FF4B61F3FF4B61
|
||||
F3FF4B61F3FF8291F6FF3040C4FF0000000000000000FFFFFF00FFFFFF000000
|
||||
000000000000000000003040C4FF8896F6FF465DF0FF465DF0FF465DF0FF465D
|
||||
F0FF8896F6FF3040C4FF000000000000000000000000FFFFFF00FFFFFF000000
|
||||
000000000000000000333040C4FF8F9DF5FF4159EEFF4159EEFF4159EEFF4159
|
||||
EEFF8F9DF5FF3040C4FF000000330000000000000000FFFFFF00FFFFFF000000
|
||||
0000000000333040C4FF97A3F5FF3C55ECFF3C55ECFF3C55ECFF3C55ECFF3C55
|
||||
ECFF3C55ECFF97A3F5FF3040C4FF0000003300000000FFFFFF00FFFFFF000000
|
||||
00333040C4FF9EABF4FF3751EAFF3751EAFF3751EAFF9EABF4FF9EABF4FF3751
|
||||
EAFF3751EAFF3751EAFF9EABF4FF3040C4FF00000033FFFFFF00FFFFFF003040
|
||||
C4FFA7B3F5FF324DE7FF324DE7FF324DE7FFA7B3F5FF3040C4FF3040C4FFA7B3
|
||||
F5FF324DE7FF324DE7FF324DE7FFA7B3F5FF3040C4FFFFFFFF00FFFFFF003040
|
||||
C4FFB0BBF5FF2D49E5FF2D49E5FFB0BBF5FF3040C4FF00000000000000003040
|
||||
C4FFB0BBF5FF2D49E5FF2D49E5FFB0BBF5FF3040C4FFFFFFFF00FFFFFF000000
|
||||
00003040C4FFBAC3F6FFBAC3F6FF3040C4FF0000000000000000000000000000
|
||||
00003040C4FFBAC3F6FFBAC3F6FF3040C4FF00000000FFFFFF00FFFFFF000000
|
||||
0000000000003040C4FF3040C4FF000000000000000000000000000000000000
|
||||
0000000000003040C4FF3040C4FF0000000000000000FFFFFF00
|
||||
}
|
||||
OnClick = BtnClearAllClick
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,26 +17,20 @@ type
|
||||
{ TGPSListViewer }
|
||||
|
||||
TGPSListViewer = class(TForm)
|
||||
BtnClearAll: TBitBtn;
|
||||
BtnDeletePoint: TBitBtn;
|
||||
BtnGoToPoint: TBitBtn;
|
||||
BtnClose: TBitBtn;
|
||||
ListView: TListView;
|
||||
Panel1: TPanel;
|
||||
procedure BtnClearAllClick(Sender: TObject);
|
||||
procedure BtnCloseClick(Sender: TObject);
|
||||
procedure BtnDeletePointClick(Sender: TObject);
|
||||
procedure BtnGoToPointClick(Sender: TObject);
|
||||
procedure ListViewDblClick(Sender: TObject);
|
||||
procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean);
|
||||
private
|
||||
FViewer: TMapView;
|
||||
FList: TGpsObjList;
|
||||
procedure SetViewer(AValue: TMapView);
|
||||
protected
|
||||
procedure Populate;
|
||||
procedure UpdateButtonStates;
|
||||
|
||||
public
|
||||
destructor Destroy; override;
|
||||
@ -83,15 +77,15 @@ begin
|
||||
for i:=0 to FList.Count-1 do begin
|
||||
gpsObj := FList[i];
|
||||
item := ListView.Items.Add;
|
||||
item.Caption := gpsObj.Name;
|
||||
// item.Caption := IntToStr(gpsObj.ID);
|
||||
if gpsObj is TGpsPoint then begin
|
||||
item.SubItems.Add(gpsObj.Name);
|
||||
item.Subitems.Add(FormatFloat(GPS_FORMAT, TGpsPoint(gpsObj).Lat));
|
||||
item.Subitems.Add(FormatFloat(GPS_FORMAT, TGpsPoint(gpsObj).Lon));
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ListView.items.EndUpdate;
|
||||
UpdateButtonStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -100,12 +94,6 @@ begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.BtnClearAllClick(Sender: TObject);
|
||||
begin
|
||||
FViewer.GpsItems.Clear(_CLICKED_POINTS_);
|
||||
ListView.Items.Clear;
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
|
||||
var
|
||||
gpsObj: TGpsObj;
|
||||
@ -113,20 +101,18 @@ var
|
||||
rPt: TRealPoint;
|
||||
item: TListItem;
|
||||
begin
|
||||
if ListView.itemIndex > -1 then begin
|
||||
ListView.Items.Delete(ListView.ItemIndex);
|
||||
// Clear all GPS items in MapViewer
|
||||
if ListView.Selected <> nil then begin
|
||||
gpsObj := FList[ListView.Selected.Index];
|
||||
ListView.Selected.Free;
|
||||
FViewer.GpsItems.Clear(_CLICKED_POINTS_);
|
||||
// Recreate remaining GPS items from data in ListView
|
||||
for i:=0 to ListView.Items.Count-1 do begin
|
||||
item := ListView.Items[i];
|
||||
rPt.Lon := StrToFloat(item.SubItems[1]);
|
||||
rPt.Lat := StrToFloat(item.SubItems[0]);
|
||||
rPt.Lon := StrToFloat(item.SubItems[2]);
|
||||
rPt.Lat := StrToFloat(item.SubItems[1]);
|
||||
gpsObj := TGpsPoint.CreateFrom(rPt);
|
||||
gpsObj.Name := item.Caption;
|
||||
gpsObj.Name := item.SubItems[0];
|
||||
FViewer.GPSItems.Add(gpsObj, _CLICKED_POINTS_);
|
||||
end;
|
||||
UpdateButtonStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -135,8 +121,8 @@ var
|
||||
gpsPt: TGpsPoint;
|
||||
gpsObj: TGpsObj;
|
||||
begin
|
||||
if ListView.ItemIndex > -1 then begin
|
||||
gpsObj := FList[ListView.ItemIndex];
|
||||
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;
|
||||
@ -144,17 +130,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.ListViewDblClick(Sender: TObject);
|
||||
begin
|
||||
BtnGotoPointClick(nil);
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.ListViewSelectItem(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean);
|
||||
begin
|
||||
UpdateButtonStates;
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.SetViewer(AValue: TMapView);
|
||||
begin
|
||||
if FViewer = AValue then
|
||||
@ -163,11 +138,5 @@ begin
|
||||
Populate;
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.UpdateButtonStates;
|
||||
begin
|
||||
BtnGotoPoint.Enabled := ListView.ItemIndex > -1;
|
||||
BtnDeletePoint.Enabled := ListView.ItemIndex > -1;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -9,8 +9,9 @@ object MainForm: TMainForm
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
ShowHint = True
|
||||
LCLVersion = '2.1.0.0'
|
||||
object Panel1: TPanel
|
||||
object ControlPanel: TPanel
|
||||
Left = 632
|
||||
Height = 545
|
||||
Top = 0
|
||||
@ -22,8 +23,8 @@ object MainForm: TMainForm
|
||||
object CbProviders: TComboBox
|
||||
AnchorSideLeft.Control = LblProviders
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideTop.Control = ControlPanel
|
||||
AnchorSideRight.Control = ControlPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 69
|
||||
Height = 23
|
||||
@ -39,7 +40,7 @@ object MainForm: TMainForm
|
||||
TabOrder = 0
|
||||
end
|
||||
object LblProviders: TLabel
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Control = ControlPanel
|
||||
AnchorSideTop.Control = CbProviders
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 9
|
||||
@ -82,7 +83,7 @@ object MainForm: TMainForm
|
||||
AnchorSideLeft.Control = CbProviders
|
||||
AnchorSideTop.Control = CbDoubleBuffer
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = ControlPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 69
|
||||
Height = 40
|
||||
@ -97,7 +98,7 @@ object MainForm: TMainForm
|
||||
TabOrder = 3
|
||||
end
|
||||
object LblZoom: TLabel
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Control = ControlPanel
|
||||
AnchorSideTop.Control = ZoomTrackBar
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 9
|
||||
@ -365,10 +366,21 @@ object MainForm: TMainForm
|
||||
OnClick = Button1Click
|
||||
TabOrder = 10
|
||||
end
|
||||
object GPSPointInfo: TLabel
|
||||
Left = 8
|
||||
Height = 80
|
||||
Top = 456
|
||||
Width = 222
|
||||
AutoSize = False
|
||||
Caption = 'GPSPointInfo'
|
||||
ParentColor = False
|
||||
WordWrap = True
|
||||
end
|
||||
end
|
||||
object MapView: TMapView
|
||||
Left = 0
|
||||
Height = 545
|
||||
Hint = 'Displays the map'
|
||||
Top = 0
|
||||
Width = 632
|
||||
Active = False
|
||||
|
@ -27,6 +27,7 @@ type
|
||||
InfoCenterLatitude: TLabel;
|
||||
InfoCenterLongitude: TLabel;
|
||||
Label1: TLabel;
|
||||
GPSPointInfo: TLabel;
|
||||
Label8: TLabel;
|
||||
LblCenterLatitude: TLabel;
|
||||
LblPositionLongitude: TLabel;
|
||||
@ -38,7 +39,7 @@ type
|
||||
LblZoom: TLabel;
|
||||
MapView: TMapView;
|
||||
GeoNames: TMVGeoNames;
|
||||
Panel1: TPanel;
|
||||
ControlPanel: TPanel;
|
||||
ZoomTrackBar: TTrackBar;
|
||||
procedure BtnGoToClick(Sender: TObject);
|
||||
procedure BtnSearchClick(Sender: TObject);
|
||||
@ -214,6 +215,7 @@ begin
|
||||
CbProviders.ItemIndex := CbProviders.Items.Indexof(MapView.MapProvider);
|
||||
MapView.DoubleBuffered := true;
|
||||
MapView.Zoom := 1;
|
||||
ControlPanel.Caption := '';
|
||||
CbUseThreads.Checked := MapView.UseThreads;
|
||||
CbDoubleBuffer.Checked := MapView.DoubleBuffered;
|
||||
|
||||
@ -244,24 +246,43 @@ end;
|
||||
|
||||
procedure TMainForm.MapViewMouseMove(Sender: TObject; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
const
|
||||
DELTA = 3;
|
||||
var
|
||||
rPt: TRealPoint;
|
||||
rArea: TRealArea;
|
||||
gpsList: TGpsObjList;
|
||||
L: TStrings;
|
||||
i: Integer;
|
||||
begin
|
||||
(*
|
||||
p := MapView.GetMouseMapPixel(X, Y);
|
||||
LblZoom.Caption := Format('Pixel: %d:%d', [p.X, p.Y]);
|
||||
p := mv.GetMouseMapTile(X, Y);
|
||||
Label3.Caption := Format('Tile: %d:%d', [p.X, p.Y]);
|
||||
r := mv.GetMouseMapLongLat(X, Y);
|
||||
*)
|
||||
rPt := MapView.Center;
|
||||
InfoCenterLongitude.Caption := Format('%.6f°', [rPt.Lon]);
|
||||
InfoCenterLatitude.Caption := Format('%.6f°', [rPt.Lat]);
|
||||
|
||||
rPt := MapView.ScreenToLonLat(Point(X, Y));
|
||||
InfoPositionLongitude.Caption := Format('%.6f°', [rPt.Lon]);
|
||||
InfoPositionLatitude.Caption := Format('%.6f°', [rPt.Lat]);
|
||||
|
||||
rPt := MapView.Center;
|
||||
InfoCenterLongitude.Caption := Format('%.6f°', [rPt.Lon]);
|
||||
InfoCenterLatitude.Caption := Format('%.6f°', [rPt.Lat]);
|
||||
rArea.TopLeft := MapView.ScreenToLonLat(Point(X-DELTA, Y-DELTA));
|
||||
rArea.BottomRight := MapView.ScreenToLonLat(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 + ' (lat=%.6f°, lon=%.6f°)', [Name, Lat, Lon]));
|
||||
GPSPointInfo.Caption := L.Text;
|
||||
finally
|
||||
L.Free;
|
||||
end;
|
||||
end else
|
||||
GPSPointInfo.Caption := '';
|
||||
finally
|
||||
gpsList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.MapViewMouseUp(Sender: TObject; Button: TMouseButton;
|
||||
|
Loading…
Reference in New Issue
Block a user