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?

Hornbydd
44.9k5 gold badges43 silver badges84 bronze badges
asked Jul 5, 2011 at 12:03

2 Answers 2

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.

answered Jul 5, 2011 at 12:34
1
  • 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... Commented Jul 5, 2011 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()
Hornbydd
44.9k5 gold badges43 silver badges84 bronze badges
answered Jul 5, 2011 at 12:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.