Using longitude and latitude to show location results in a incorrect location

Discussion created by somnuslee1988 on Dec 18, 2013
Latest reply on Dec 20, 2013 by NSager-esristaff
Hi, all

I am new to arcgis for iOS, now I encounter a strange problem, and I have looked into other threads but haven't find any solutions.

I want to show a building which longitude is 116.929167 and latitude is 34.727222 on my graphic layer. My base map layer is in a
WGS84 spatial reference.

However, when I first tried the following code, it results in the point being misplaced.
Note: the place is somewhere in Jangsu Province, China, but it was placed in Hunan Province, China.

self.mapView.layerDelegate = self;
 //create an instance of a tiled map service layer
 AGSTiledMapServiceLayer *tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:[NSURL URLWithString:kTiledMapServiceURL]];
 //Add it to the map view
 [self.mapView addMapLayer:tiledLayer withName:@"Tiled Layer"];
 //release to avoid memory leaks
    //set the callout delegate so we can display callouts
    self.mapView.callout.delegate = self;
    //add  graphics layer for the graphics
    self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];
    //add the graphics layer to the map
    [self.mapView addMapLayer:self.graphicsLayer withName:@"Graphics Layer"];
    //zoom to china
    AGSEnvelope *chinaEnv = [AGSEnvelope envelopeWithXmin:78.0000000
                                        spatialReference:[AGSSpatialReference wgs84SpatialReference]];

    [self.mapView zoomToEnvelope:chinaEnv animated:YES];

    self.mapView.callout.customView = nil;

    self.mapView.callout.accessoryButtonHidden = YES;

    double longitude = 116.929167;
    double latitude = 34.727222;

    AGSPoint *graphicPoint = [AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]];

    [self.mapView.callout showCalloutAt:graphicPoint screenOffset:CGPointMake(0, 0) animated:YES];

Can anyone tell me why it cannot show the correct location and how to fix this problem?
Thank you very much for your time and answers!
Best Regards.