You've already forked lazarus-ccr
LazMapViewer: Add new TMapView method ObjsAtScreenPt to detect the GPS object under the mouse.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8106 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -122,6 +122,7 @@ Type
|
||||
procedure GetMapProviders(lstProviders: TStrings);
|
||||
function GetVisibleArea: TRealArea;
|
||||
function LonLatToScreen(aPt: TRealPoint): TPoint;
|
||||
function ObjsAtScreenPt(X, Y: Integer; ATolerance: Integer = -1): TGPSObjarray;
|
||||
procedure SaveToFile(AClass: TRasterImageClass; const AFileName: String);
|
||||
function SaveToImage(AClass: TRasterImageClass): TRasterImage;
|
||||
procedure SaveToStream(AClass: TRasterImageClass; AStream: TStream);
|
||||
@@ -943,6 +944,33 @@ begin
|
||||
Engine.Jobqueue.WaitAllJobTerminated(Engine);
|
||||
end;
|
||||
|
||||
function TMapView.ObjsAtScreenPt(X, Y: Integer; ATolerance: Integer = -1): TGPSObjarray;
|
||||
const
|
||||
DELTA = 3;
|
||||
var
|
||||
rArea: TRealArea;
|
||||
gpsList: TGPSObjList;
|
||||
i: Integer;
|
||||
begin
|
||||
if ATolerance = -1 then
|
||||
ATolerance := DELTA;
|
||||
|
||||
// Define area of +/-ATolerance pixels around the screen point
|
||||
rArea.TopLeft := ScreenToLonLat(Point(X-ATolerance, Y-ATolerance));
|
||||
rArea.BottomRight := ScreenToLonLat(Point(X+ATolerance, Y+ATolerance));
|
||||
|
||||
// Collect Objects in this are
|
||||
gpsList := FGPSItems.GetObjectsInArea(rArea);
|
||||
try
|
||||
SetLength(Result, gpsList.Count);
|
||||
for i := 0 to gpsList.Count-1 do
|
||||
if gpsList[i] is TGPSPoint then
|
||||
Result[i] := gpsList[i];
|
||||
finally
|
||||
gpsList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMapView.CenterOnObj(obj: TGPSObj);
|
||||
var
|
||||
Area: TRealArea;
|
||||
|
||||
Reference in New Issue
Block a user