panning with code

622
2
Jump to solution
08-17-2012 01:57 PM
ForamParikh
Occasional Contributor
Hello experts,

I want to implement panning while editing feature.I am not using editor so i have to write it in the code i am using below code which is working fine but it pan the whole window i want it should pan little bit.

below is my code,

  if (e.Key.ToString().ToUpper() == "LEFT")
            {
                Envelope extent = MyMap.Extent;
                MapPoint center = extent.GetCenter();
                MyMap.PanTo(new MapPoint(extent.XMin, center.Y));
            }
            else if (e.Key.ToString().ToUpper() == "RIGHT")
            {
                Envelope extent = MyMap.Extent;
                MapPoint center = extent.GetCenter();
                MyMap.PanTo(new MapPoint(extent.XMax, center.Y));
            }

Please help,

Thanks
Foram
0 Kudos
1 Solution

Accepted Solutions
TerryGiles
Occasional Contributor III
Foram,

Instead of panning all the way to the min or max of the current extent, you might try using a fraction of the extent's width.  Example below shifts it 1/4 east or west

 Envelope extent = MyMap.Extent; MapPoint center = extent.GetCenter();  if (e.Key.ToString().ToUpper() == "LEFT") {  MyMap.PanTo(new MapPoint(center.X - (extent.Width/4), center.Y)); } else if (e.Key.ToString().ToUpper() == "RIGHT") {   MyMap.PanTo(new MapPoint(center.X + (extent.Width/4), center.Y)); } 

View solution in original post

0 Kudos
2 Replies
TerryGiles
Occasional Contributor III
Foram,

Instead of panning all the way to the min or max of the current extent, you might try using a fraction of the extent's width.  Example below shifts it 1/4 east or west

 Envelope extent = MyMap.Extent; MapPoint center = extent.GetCenter();  if (e.Key.ToString().ToUpper() == "LEFT") {  MyMap.PanTo(new MapPoint(center.X - (extent.Width/4), center.Y)); } else if (e.Key.ToString().ToUpper() == "RIGHT") {   MyMap.PanTo(new MapPoint(center.X + (extent.Width/4), center.Y)); } 
0 Kudos
ForamParikh
Occasional Contributor
Thanks it works
0 Kudos