Good day

I was working with the info tool code used in the article http://testdrive.mapinfo.com/techsupp/miprod.nsf/0/89c695ce5f2fab4185256f0f005873bf?OpenDocument&ExpandSection=4%2C2#_Section4

I'm using mapxtreme 6.2 and visual .net 2003, I copied the code and followed the instructions, and yet, when I run the application and click on the info tool button, I get the following error:
"An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mapinfo.coreengine.dll

Additional information: The specified argument is outside the range of valid values."
What can I do to fix the issue?
Thanks in advance.

 

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

 

 

 Carlos Martín

 Supervisor de Informática

 tel.

+58

(241)

824-4443

 fax.

+58

(241)

824-5686

 cel.

+58

(414)

412-9170

 

 

 

 

 [EMAIL PROTECTED]

 http://www.logistica.com.ve

 

_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to