Select to view content in your preferred language

Coordinates WGS84 self.mapView.visibleAreaEnvelope.center.x

1671
2
Jump to solution
05-18-2014 04:30 PM
MauricioSalazar
Deactivated User
Hi, i am trying to show the wgs84 coordinates at center of:

LongCentro.text = [NSString stringWithFormat:@"Long: %.4f", self.mapView.visibleAreaEnvelope.center.x];

with this obtain in other spatial reference but i try to transform to wgs84,

LatCentro.text = [NSString stringWithFormat:@"Long: %.4f", [mapView visibleAreaEnvelope].center.y spatialReference:WKID_WGS_1984_WEB_MERCATOR];

but is wrong!

Thanks for the answers.
0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor
If your map is not in WGS84 spatial reference, you need to project the center point of the map's visible area first.

    AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine];     AGSPoint* mapPoint = self.mapView.visibleAreaEnvelope.center;     AGSPoint* wgs84Point = (AGSPoint*)[engine projectGeometry:mapPoint toSpatialReference:[AGSSpatialReference wgs84SpatialReference]]; LongCentro.text = [NSString stringWithFormat:@"Long: %.4f", wgs84Point.x];

View solution in original post

0 Kudos
2 Replies
DiveshGoyal
Esri Regular Contributor
If your map is not in WGS84 spatial reference, you need to project the center point of the map's visible area first.

    AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine];     AGSPoint* mapPoint = self.mapView.visibleAreaEnvelope.center;     AGSPoint* wgs84Point = (AGSPoint*)[engine projectGeometry:mapPoint toSpatialReference:[AGSSpatialReference wgs84SpatialReference]]; LongCentro.text = [NSString stringWithFormat:@"Long: %.4f", wgs84Point.x];
0 Kudos
MauricioSalazar
Deactivated User
Thank you, is exactly that looking for!
0 Kudos