Zoom to Point Feature and Set Scale

1667
3
04-22-2010 02:48 PM
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
Reply
0 Kudos
3 Replies
New Contributor
You need to calculate the Extent, and then you can set IMap.Extent to zoom the map to a specific scale.
Reply
0 Kudos
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
Reply
0 Kudos
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
Reply
0 Kudos