Trying to center the map on a feature... need to convert the feature's XY?

583
1
Jump to solution
06-11-2012 01:24 PM
RameshSivaraman
New Contributor II
My base map is the Bing Hybrid map, and I have loaded an XY event layer with a specified a coordinate transformation (in this case esriSRProjCSType.esriSRProjCS_NAD1927SPCS_CAV).  How can I get the appropriate IPoint to pass into the CenterAt() call on the map control?  If I get the X/Y from the feature, it is the unconverted X/Y I originally gave it and not appropriate for using to create a Point for the CenterAt() call.  I looked into the transformations between systems but could not find a predefined transformation that would go between the system Bing is using and the one for which I have my X/Y data. 

Can anyone give any pointers?

Thanks!  John
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RameshSivaraman
New Contributor II
Nevermind, got it.... for anyone else struggling similarly, the trick was using the SpacialReference in the MapControl:

    IPoint pt = new Point();
    ISpatialReferenceFactory srFact = new SpatialReferenceEnvironment();
    pt.SpatialReference = (IProjectedCoordinateSystem)srFact.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1927SPCS_CAV);
    pt.PutCoords(myX, myY);
    pt.Project(axMapControl1.SpatialReference);
    axMapControl1.CenterAt(pt);

View solution in original post

0 Kudos
1 Reply
RameshSivaraman
New Contributor II
Nevermind, got it.... for anyone else struggling similarly, the trick was using the SpacialReference in the MapControl:

    IPoint pt = new Point();
    ISpatialReferenceFactory srFact = new SpatialReferenceEnvironment();
    pt.SpatialReference = (IProjectedCoordinateSystem)srFact.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1927SPCS_CAV);
    pt.PutCoords(myX, myY);
    pt.Project(axMapControl1.SpatialReference);
    axMapControl1.CenterAt(pt);
0 Kudos