0

I am using the AxMapControl to display a map and I want to record a point where I am and want to be able to return to the same point later on using the CenterAt() method.

1
  • Welcome to GIS SE! Would you be able to edit your Question to provide a few more details (code snippets) to show what you have tried and where you are stuck, please? – PolyGeo Jun 13 '14 at 6:58
1

The AxMapcontrol has a property Extent which returns an envelope, from this the average X and average Y would be the centre:

double CentX = ( MapControl.Extent.Xmin + MapControl.Extent.Xmax ) / 2;
double CentY = ( MapControl.Extent.Ymin + MapControl.Extent.Ymax ) / 2;

IPoint CentPoint = new PointClass();
IPoint.PutCoords(CentX,CentY);
IPoint.SpatialReference = MapControl.SpatialReference;

You can CenterAt() this IPoint later, the spatial reference is the same as the map so you should have no problems.. you could consider keeping the extent object if you want the map to zoom to exactly the same spot with the same scale.

0

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.