AGSPoint *pt = addressCandidate.location; AGSMutablePoint *newPoint = [AGSMutablePoint pointWithX:pt.x y:pt.y spatialReference:self.mapView.spatialReference];
This was very helpful for me and solved my problem of converting between coordinate systems.
Thank you.
AGSSpatialReference* outSR = [AGSSpatialReference spatialReferenceWithWKID:31259 WKT:nil]; [self.locator locationsForAddress:addresses returnFields:outFields outSpatialReference:outSR];
Candidate : AGSPoint: x = 15.441723, y = 47.067916, spatial reference: [(null)]
[self.gst projectGeometries:self.geometryArray:outSR];
[self.gst projectGeometries:self.geometryArray toSpatialReference:outSR];
- (void)geometryServiceTask:(AGSGeometryServiceTask *)geometryServiceTask operation:(NSOperation *)op didReturnProjectedGeometries:(NSArray *)projectedGeometries { NSLog(@"didReturnProjectedGeometries"); } - (void)geometryServiceTask:(AGSGeometryServiceTask *)geometryServiceTask operation:(NSOperation*)op didFailProjectWithError:(NSError *)error { NSLog(@"didFailProjectWithError"); }
below formula converts 4326 latitude to 102100 latitude
+ (double)toWebMercatorY:(double)latitude
{
double rad = latitude * 0.0174532;
double fsin = sin(rad);
double y = 6378137 / 2.0 * log((1.0 + fsin) / (1.0 - fsin));
return y;
}
below formula converts 4326 longitude to 102100 longitude
+ (double)toWebMercatorX:(double)longitude
{
double x = longitude * 0.017453292519943 * 6378137;
return x;
}
See my attachment , it contains a utility mercator convertor . You can simply import the class in your project and call the above static methods on it
I have tried it with location manager and it works!!!
Regards,
Harikant Jammi