Select to view content in your preferred language

arcEngine zoom control

468
0
06-11-2010 08:03 AM
TimParis
Emerging Contributor
Is there a way to mimic the functionality of the drop down list zoom control that comes with arcEngine?

I have a zoom slider with plus/minus buttons that I have created and I would like to be able to zoom to a specific LODInfo level based on what is in my dynamic cache.  I have figured out how to obtain all possible LODInfo levels (but not available) but when I attempt to set the extent of the active view to a specific resolution, it doesn't fully do it.  ie:  I can expand the envelope to match the resolution of LODInfo 11 and set the active view extent to that envelope, but the map doesn't fully zoom to LODInfo 11, sometimes it will take 3 attempts of setting it to the same resolution to get it into LODInfo 11.

Basically, given the scale and resolution from an LODInfo, how do I zoom to that LODInfo?

//zoom out
IActiveView pActiveView = (IActiveView)m_hookHelper.FocusMap;
IEnvelope pEnvelope = (IEnvelope)pActiveView.Extent;
double currentResolution = pEnvelope.width / m_deviceFrame.right;
double newResolution = 0;
int newLevelID = 0;
foreach (LODInfo lodInfo in m_lodInfoList)
{
   if (currentResolution > lodInfo.Resolution) break;
   newResolution = lodInfo.Resolution;
   newLevelID = lodInfo.LevelID;
}
double dx = m_deviceFrame.right * newResolution - pEnvelope.width;
double dy = m_deviceFrame.bottom * newResolution - pEnvelope.height;
pEnvelope.Expand(dx,dy,false);
pActiveView.Extent = pEnvelope;
pActiveView.Refresh();
0 Kudos
0 Replies