Getting Lat/Long from Camera point

366
2
Jump to solution
07-27-2022 12:03 PM
BrianBulla
Honored Contributor

Hi,

I'm trying to get the the Lat/Long coordinates of the active MapView Camera point.  I can get the Camera point in X/Y, but having trouble converting.  This is how I am doing it:

MapPoint cameraPoint = MapPointBuilder.CreateMapPoint(Camera.X, Camera.Y);
var projectedPoint = GeometryEngine.Instance.Project(cameraPoint, SpatialReferences.WGS84) as MapPoint;

 

Any guidance is appreciated.

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

When you create the MapPoint you have to include the Camera's spatial reference.  This worked for me, but it's Pro 3.0:

MapPoint cameraPoint = MapPointBuilderEx.CreateMapPoint(cameraBefore.X,
  cameraBefore.Y, cameraBefore.SpatialReference);
var projectedPoint = GeometryEngine.Instance.Project(cameraPoint, SpatialReferences.WGS84) as MapPoint;
MessageBox.Show($@"projected [x,y]: {projectedPoint.X}, {projectedPoint.Y}");

 

View solution in original post

2 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

When you create the MapPoint you have to include the Camera's spatial reference.  This worked for me, but it's Pro 3.0:

MapPoint cameraPoint = MapPointBuilderEx.CreateMapPoint(cameraBefore.X,
  cameraBefore.Y, cameraBefore.SpatialReference);
var projectedPoint = GeometryEngine.Instance.Project(cameraPoint, SpatialReferences.WGS84) as MapPoint;
MessageBox.Show($@"projected [x,y]: {projectedPoint.X}, {projectedPoint.Y}");

 

BrianBulla
Honored Contributor

Thanks Wolf.  Here is my 2.9 code that is now working.

MapPoint cameraPoint = MapPointBuilder.CreateMapPoint(Camera.X, Camera.Y, Camera.SpatialReference);
var projectedPoint = GeometryEngine.Instance.Project(cameraPoint, SpatialReferences.WGS84) as MapPoint;
0 Kudos