Zoom to Point Feature and Set Scale

1857
3
04-22-2010 02:48 PM
AdamVellutini
New Contributor III
I am set up to zoom to a selected point through a button on a custom form.  My map centers on the point just fine.  I would like to zoom in on that point rather than remain at the scale I am at.  Say, zoom to a 2400 scale.  Is there a way that I can set that while zooming to my point?

Thanks, Adam
0 Kudos
3 Replies
SaqibMehmood
New Contributor
You need to calculate the Extent, and then you can set IMap.Extent to zoom the map to a specific scale.
0 Kudos
MichaelKartusch
New Contributor
I am having trouble zooming to a selected point.  My code selects the point just fine, but the code I used to zoom to a selected polygon does not work when I try applying it to a point.  I have separate buttons in my project, one executes the zoom to a selected polygon, while the other button is designed to execute a zoom to a selected point.  Any ideas?

  ' Now do the zoom to the selected features
  Dim pSelSet As ISelectionSet
  Set pSelSet = pFeatureSelection.SelectionSet
  Dim pEnumGeom As IEnumGeometry
  Dim pEnumGeomBind As IEnumGeometryBind
 
  Set pEnumGeom = New EnumFeatureGeometry
  Set pEnumGeomBind = pEnumGeom
  pEnumGeomBind.BindGeometrySource Nothing, pSelSet
 
  Dim pGeomFactory As IGeometryFactory
  Set pGeomFactory = New GeometryEnvironment
 
  Dim pGeom As IGeometry
  Set pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom)
 
  pMxDoc.ActiveView.Extent = pGeom.Envelope
  pFeatureSelection.Clear
  pMxDoc.ActiveView.Refresh
  pMxDoc.PageLayout.ZoomToWhole

Thanks,
Michael
0 Kudos
JeffMatson
Occasional Contributor III
A single point will not have an envelope.  What you can do instead is:

create a new Envelope and set it to your activeView.Extent
center the Envelope on your point using Envelope.CenterAt
set your activeView.Extent to the modified Envelope
optionally modify the map scale
refresh

If you want to use this in conjunction with your zoom to polygon code you could check the type of geometry, i.e.:

If Geometry.GeometryType = esriGeometryPoint then
'center on point
Else
'zoom to polygon/polyline/mutipoint etc.
End if
0 Kudos