AnsweredAssumed Answered

AGSSimpleMarkerSymbol not showing up where expected

Question asked by msullivan@paradigmisr on Feb 9, 2015
Latest reply on Apr 30, 2015 by milack

I'm completely new to ArcGIS for iOS. It's extremely interesting but I'm not understanding something. I'm creating an AGSGraphicsLayer and adding an AGSSimpleMarkerSymbol to it. The symbol is showing up on my map but not where I expected it. I'm wondering if this is somehow related to the dread AGSSpatialReference, which I don't fully understand at this point.

 

What I'm doing is zooming in on the user's location, using an AGSEnvelope determined from the user's location. This works fine. I'm then attempting to drop a red-coloured pin quite close to the blue pin that shows my location. Here's the first part:

 

    AGSLocation* location = self.mapView.locationDisplay.location;

    double lon = location.point.x;

    double lat = location.point.y;

    double extent = 0.01;

   

    AGSEnvelope* env = [AGSEnvelope envelopeWithXmin:lon - extent

                                                ymin:lat - extent

                                                xmax:lon + extent

                                                ymax:lat + extent

                                    spatialReference:[AGSSpatialReference wgs84SpatialReference]];

 

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

    NSLog(@"zoomToUsersLocation: {%.6f, %.6f}", lon, lat);

 

I'll skip the bit of code where I create the symbol because it works fine, but when I attempt to place the symbol onto the graphics layer I created earlier, it shows up far away from where I expected. (I live on the west Coast of Canada, and that's where the blue pin from the above code shows I am, while the red symbol ends up on the west coast of Africa! :-)

 

AGSPoint* nearUserPt = [AGSPoint pointWithX:lon + .001

                                                                          y:lat + .001

                                                    spatialReference:self.mapView.spatialReference];

 

    NSLog(@"nearUserPt: {%.6f, %.6f}", nearUserPt.x, nearUserPt.y);

    AGSGraphic* graphic = [AGSGraphic graphicWithGeometry:nearUserPt

                                                   symbol:symbol

                                                attributes:nil

                                     infoTemplateDelegate:nil];

    AGSGraphicsLayer* graphicsLayer = (AGSGraphicsLayer*)[self.mapView mapLayerForName:@"Graphics Layer"];

    [graphicsLayer addGraphic:graphic];

 

The final confusing thing is that when I print the two above NSLog() statements to the console, they both print the same longitude and latitude (with the very minor difference of the delta I'm using to offset them slightly on the map). But the points on the map are literally two continents apart.

 

Am I misunderstanding something about spatial references perhaps???

Howard

Outcomes