1

I find a feature by using IFeatureClass.Search then I want to show the feature on the screen.

How can I do that ?

Is there a zoom interface or something else?

2

Set the Extent of the map to be the envelope of the feature/features see Zooming in on the map Sample in the documentation.

  • Thanks so much four your answer.i was searching for the feature which the geometry type is point.I used IEnvelope.CenterAt() method to change the extent of the map.Thanks again.Greetings... – caner Jul 5 '11 at 13:05
2

You could use IFeature to zoom to the extent of the active view envelope, example below.

Dim pEnv as IEnvelope
pFCursor = pFClass.Search(pQFilt, True)
pFeature = pFCursor.NextFeature
If pFeature Is Nothing Then
    'MsgBox "Check spelling and case", vbCritical + vbExclamation, "State Not Found!"
Else
    pActView.Extent = pFeature.Shape.Envelope
    Set pEnv = pActView.Extent
    pEnv.Expand 1.1, 1.1, True
    pActView.Extent = pEnv
End If

OR

Select the record and zoom to it, example below.

' Part 1: Create a cursor of interstates.
Dim pFeatureLayer As IFeatureLayer
Dim pFeatureLayer2 As IFeatureLayer
Dim pFeatureSelection2 As IFeatureSelection = Nothing
Dim pFc As IFeatureClass
Dim pQueryFilter As IQueryFilter
Dim pSelSet As ISelectionSet
Dim pFCur As IFeatureCursor = Nothing
Dim player As ILayer
Dim pEnumLayer As IEnumLayer
Dim pEnumLayer2 As IEnumLayer = Nothing
Dim lngFldPDFLink As Int32

m_pMap2 = m_pMxDoc2.ActiveView.FocusMap
pEnumLayer = m_pMap2.Layers

player = pEnumLayer.Next
Do Until player Is Nothing
    If player.Name = "My Layer" Then
        pFeatureLayer = CType(player, IFeatureLayer)
        pFeatSelection = CType(pFeatureLayer, IFeatureSelection)
    End If
    player = pEnumLayer.Next
Loop

' Select interstates.
pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "FID <> 99999"
pFeatSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
' Create a feature cursor of selected interstates.
pSelSet = pFeatSelection.SelectionSet
pSelSet.Search(Nothing, False, pFCur)
m_pMap2 = m_pMxDoc2.ActiveView.FocusMap
pEnumLayer2 = m_pMap2.Layers    

'Zoom selected features
Dim pUID As New UID
Dim pCmdItem As ICommandItem
' Use the GUID of the Save command
pUID.Value = "{AB073B49-DE5E-11D1-AA80-00C04FA37860}"
' or you can use the ProgID
' pUID.Value = "esriArcMapUI.MxFileMenuItem"
pUID.SubType = 3
pCmdItem = m_app2.Document.CommandBars.Find(pUID)
pCmdItem.Execute()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.