|
Good day P.D.: This is the code as is on the application, in
case it helps: Public Sub infotool1() Dim ptMapTool As MapInfo.Tools.MapTool = New
MapInfo.Tools.CustomPointMapTool(False,
Me.MapControl1.Tools.FeatureViewer,
Me.MapControl1.Handle.ToInt32(),
Me.MapControl1.Tools, Me.MapControl1.Tools.MouseToolProperties,
Me.MapControl1.Tools.MapToolProperties) Me.MapControl1.Tools.Add("InfoTool",
ptMapTool) 'Note that the name of the tool is the
same as the ToolId which was set in the ToolBarButton Collection Editor AddHandler
MapControl1.Tools.Used, AddressOf
ToolUsed End Sub Public Sub ReturnInfo(ByVal e As MapInfo.Tools.ToolUsedEventArgs) 'clear the items in the listBox ListBox1.Items.Clear() Dim connection As New MapInfo.Data.MIConnection connection.Open() 'this is the point at which the user
clicked on the map Dim pt As New
MapInfo.Geometry.Point(Me.MapControl1.Map.GetDisplayCoordSys(),
e.MapCoordinate.x, e.MapCoordinate.y) Dim i As Int16 = 0 While i <
MapControl1.Map.Layers.Count() Dim fl As FeatureLayer = MapControl1.Map.Layers(i) If fl.VisibleRangeEnabled = True And fl.VisibleRange.Within(Me.MapControl1.Map.Zoom) Or fl.VisibleRangeEnabled = False Then 'if the layer is visible within the
current map Dim command As MapInfo.Data.MICommand =
connection.CreateCommand() command.CommandText
= "Select * from " & fl.Table.Alias & " where @pt
intersects Obj" Dim geoCol As MapInfo.Data.GeometryColumn =
fl.Table.TableInfo.Columns(0) If
geoCol.PredominantGeometryType.ToString() = "MultiCurve" Or
geoCol.PredominantGeometryType.ToString() = "Curve" Then
'Checks to see if the table is a
table of MultiCurves or Curves. We will use a buffer to search for these
features
command.Parameters.Add("@pt", pt.Buffer(Me.MapControl1.Map.Zoom.Value / 500,
MapInfo.Geometry.DistanceUnit.Mile, 99)) ElseIf
geoCol.PredominantGeometryType.ToString() = "Point" Or geoCol.PredominantGeometryType.ToString() =
"MultiPoint" Then
'Checks to see if the table is a
table of Points or MultiPoints. This buffer will be used for these features as
'well.
command.Parameters.Add("@pt", pt.Buffer(MapControl1.Map.Zoom.Value /
200, MapInfo.Geometry.DistanceUnit.Mile, 99)) Else
command.Parameters.Add("@pt", pt) End If Dim irfc As MapInfo.Data.IResultSetFeatureCollection =
command.ExecuteFeatureCollection() For Each f As MapInfo.Data.Feature In irfc
ListBox1.Items.Add(f(1).ToString()) Next
command.Dispose()
irfc.Close() End If i = i
+ 1 End While connection.Close() End Sub Public Sub ToolUsed(ByVal sender As Object,
ByVal e As
MapInfo.Tools.ToolUsedEventArgs) If e.ToolName =
"InfoTool" Then
ReturnInfo(e) End If End
Sub
|
_______________________________________________ MapInfo-L mailing list [email protected] http://www.directionsmag.com/mailman/listinfo/mapinfo-l

