I'm testing a simple portion of my add in and can't get it to center/pan to a specified point, I've included what is currently in my OnClick() method. No errors appear it just refreshes and nothing happens (10.1 SP1, C#.NET VS 2010).

IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;
IActiveView actView = mxdoc.FocusMap as IActiveView;
IPageLayout pLayout = actView as IPageLayout;
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
int gcsCode = (int)esriSRGeoCSType.esriSRGeoCS_NAD1983;
ISpatialReference spatRef = srFactory.CreateGeographicCoordinateSystem(gcsCode);

    IPoint point = new PointClass();
    double xCoord = 33.217918;
    double yCoord = -98.158749;
    point.PutCoords(xCoord, yCoord);
catch (Exception ex)
  • yCoord looks > 90 Jun 1 '16 at 15:44
  • That seems to be my next issue, no matter what projection I put it in it puts me in the Atlantic Ocean. I believe this is because it is taking me x meters from the origin but it was my understanding that a geographic coordinate system read these coordinates differently. Jun 1 '16 at 15:56

There's a few problems here. First IMxDocument.FocusMap is read only, you can't change the extent from here, use IMxDocument.ActiveView instead.

Instead of projecting your point (point.Project(spatRef);) you need to set it by using IPoint.SpatialReference (inheritied from IGeometry class): point.SpatialReference = spatRef;

I have found it better to pan an envelope rather than trying to modify with CenterAt:

IEvelope pEnv = mxdoc.ActiveView.Extent;
mxdoc.ActiveView.Extent = pEnv;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.