How to zoom to a specific scale in ArcMap 9.3 in Vb.net?

2527
4
06-06-2011 10:06 PM
dgesridgesri
Occasional Contributor II
Greetings,

I wonder if there is any way to set the scale of the "Zoom to selected Feature" functionality through Vb.Net code?

But if this is can not be done. Could I zoom to the selected feature then set the scale to the value I want similar to what we can do in ArcMap 9.3(Zoom to selected then enter the value of the scale in the scale text found on the Standard Toolbar). Is this possible? How?

Please advise...
0 Kudos
4 Replies
DuncanHornby
MVP Notable Contributor
dgesri,

What you are asking does not make sense. If you want to zoom to a selection then to zoom to the extent of that selection must alter the scale. Below is the VBA code that you could use to call the zoom to selection tool.

Public Sub ZoomToAllSelectedFeatures()
        ' Zoom to selection by calling standard tool
        Dim pCmdItem As ICommandItem
        Dim pUID As New UID
        pUID.Value = "{AB073B49-DE5E-11D1-AA80-00C04FA37860}"
        Set pCmdItem = ThisDocument.CommandBars.Find(pUID)
        pCmdItem.Execute
End Sub


Duncan
0 Kudos
dgesridgesri
Occasional Contributor II
Thank you Mr. Hornbydd for your interest on this post,

Well, I`m already using this function "ZoomToAllSelectedFeatures" but I want to change the scale of the zoom if possible.

Or I think I can change the scale of the extent after I call that function but through vb.net code. Again if this is possible, please advise?

Thanks guys...
0 Kudos
DuncanHornby
MVP Notable Contributor
You can change map scale like this:

Dim pMap As IMap
        Dim pmxDoc As IMxDocument
        Set pmxDoc = ThisDocument
        Set pMap = pmxDoc.FocusMap
        pMap.MapScale = 10000


This VBA example assumes your data frame has its coordinate system set.

Duncan
0 Kudos
dgesridgesri
Occasional Contributor II
Thank you very much Mr. Hornbydd,

I was thinking of changing the zoom scale so when I zoom to a selected feature then it zoom to the location of that selected feature but with a specific scale.

However, what you have posted about changing the map scale is another workaround and it helped me a lot..

Again thank you man...
0 Kudos