ArcEngine Zoom to Feature

1 message Options
Embed this post
Permalink
Lawrence Hartpence-3

ArcEngine Zoom to Feature

Reply Threaded More More options
Print post
Permalink
Hello,

I have developed an ArcGIS Engine application where an user may type in
a portion of a street name, a window pops up with a list of the street
names that are possible, then the user clicks on the street name they
want.  At this point, the map is supposed to zoom to the street segment
for which the user clicked.  The problem is that the map does nothing.
Below is the code I am using.  I would appreciate anyone who could look
this over an tell me what I am missing?

Thanks,

Lawrence Hartpence
GIS Analyst
4200 Mills Civic Pkwy
West Des Moines IA 50265

515-273-0620

[hidden email]


Private Sub DataGridView1_MouseDoubleClick(ByVal sender As Object, ByVal
e As System.Windows.Forms.MouseEventArgs) Handles
DataGridView1.MouseDoubleClick
        'MsgBox(DataGridView1.CurrentRow.Cells(0).Value)
        Dim pMapDocument As ESRI.ArcGIS.Carto.IMapDocument = New
ESRI.ArcGIS.Carto.MapDocumentClass()
        Dim Path As String
        Path = "\\wscp1as01\LG Products\WestComDocs\AddressMap.mxd"
        pMapDocument.Open(Path, Nothing)
        Dim pMap As ESRI.ArcGIS.Carto.IMap
        Dim i As Integer
        Dim pFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer

        For i = 0 To pMapDocument.MapCount - 1 Step i + 1
            pMap = pMapDocument.Map(i)
            'MsgBox(pMap.Name)
            Dim pEnumLayer As ESRI.ArcGIS.Carto.IEnumLayer =
pMap.Layers(Nothing, True)
            pEnumLayer.Reset()
            Dim pLayer As ESRI.ArcGIS.Carto.ILayer = pEnumLayer.Next()
            While Not pLayer Is Nothing
                If pLayer.Name = "StreetCenterline" Then
                    'MsgBox(pLayer.Name)
                    Exit While
                Else
                    pLayer = pEnumLayer.Next()
                End If
                pFeatureLayer = pLayer
            End While
        Next

        Dim pfClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
        If Not pFeatureLayer Is Nothing Then
            pfClass = pFeatureLayer.FeatureClass
        End If

        Dim pfeatureSelection As ESRI.ArcGIS.Carto.IFeatureSelection

        pfeatureSelection = pFeatureLayer 'QI

        Dim pEnvelope As ESRI.ArcGIS.Geometry.IEnvelope
        Dim pfeatsel As ESRI.ArcGIS.Geodatabase.IFeature
        Dim eID As Long
        eID = DataGridView1.CurrentRow.Cells(0).Value
        pfeatsel = pFeatureLayer.FeatureClass.GetFeature(eID)
        pEnvelope = pfeatsel.Shape.Envelope.Envelope
        pEnvelope.Expand(300, 300, False)

        pMapDocument.ActiveView.Activate(hWnd:=0)
        'Confirm that the map extent really does change.
        MsgBox(String.Concat("New map extent: ", pEnvelope.XMin, ", ",
pEnvelope.YMin, ", ", pEnvelope.XMax, ", ", pEnvelope.YMax))
        pMapDocument.ActiveView.Extent = pEnvelope
        pMapDocument.ActiveView.Refresh()

    End Sub