VB.NET Zoom to ObjectID

519
1
10-12-2017 03:48 AM
SigurdurGear
New Contributor

Hi

I query Address from Layer to Listview with ObjectID

how can I zoom to ObjectID 

Dim pMxDoc As IMxDocument
pMxDoc = My.ArcMap.Application.Document

Dim pMap As IMap
pMap = pMxDoc.FocusMap


Dim pFlayer As IFeatureLayer = getLayerByName(Layername)
'get the feature class
Dim pFeatureClass As IFeatureClass = pFlayer.FeatureClass

Dim pFeature As IFeature = pFeatureClass.GetFeature(ListView1.SelectedItems(0).Text)


Dim pActiveView As IActiveView
pActiveView = pMap

pMap.ClearSelection()

pMap.SelectFeature(pFlayer, pFeature)

0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor

When you post any code please format it, edit your question and follow the instructions here it allows us to follow your code and help you.

There are at least two ways to do this:

  1. Call the existing zoom to selected features button but if you have other selected features in other layers it would zoom to them all.
  2. Construct the bounding extent of your selection and zoom to that, sample code can be found here.
0 Kudos