How do I create a point using lat/lon?

624
2
Jump to solution
09-24-2012 11:19 AM
TomHicks
New Contributor II
I am new to ArcGIS iOS. It looks very promising, but I definitely need some help. I need to place images at points that are based on lat/lon. I found this code and tried it in CustomCalloutSample, but it placed my point off Africa instead of in Florida...

graphicPoint = [self agsPointFromLatitude:28.0833 longitude:-80.6083];

- (AGSPoint *)agsPointFromLatitude:(double)latitude longitude:(double)longitude     // found on Internet
{
    AGSSpatialReference *referenceGPS = [AGSSpatialReference wgs84SpatialReference];
    AGSGeometryEngine *ge = [AGSGeometryEngine defaultGeometryEngine];
    AGSPoint *graphicPoint = [AGSPoint pointWithX:longitude y:latitude spatialReference:referenceGPS];
    AGSGeometry *myPointReprojected = [ge projectGeometry:graphicPoint toSpatialReference:_mapView.spatialReference]; //[AGSSpatialReference webMercatorSpatialReference]
   
    return (AGSPoint *)myPointReprojected;
}
0 Kudos
1 Solution

Accepted Solutions
TomHicks
New Contributor II
Problem solved!  I had lat/lon reversed...was using lat for x and lon for y...

View solution in original post

0 Kudos
2 Replies
TomHicks
New Contributor II
I tried this based on another post on this forum, but graphicPoint showed up in Antarctica instead of Florida...


    AGSPoint *myPoint = [AGSPoint pointWithX:28.0833 y:-80.6083 spatialReference:[AGSSpatialReference wgs84SpatialReference]];
    AGSGeometryEngine *ge = [AGSGeometryEngine defaultGeometryEngine];
    AGSGeometry *myPointReprojected = [ge projectGeometry:myPoint toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]];
    graphicPoint = (AGSPoint*)myPointReprojected;
    graphicAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithInt:CustomInfoView], @"type",
                         @"MacDonald's", @"name",
                         @"2720 West Broadway, Louisville, KY 40211-1320", @"address",
                         @"5027787110", @"phone",
                         @"www.mcdonalds.com", @"url",
                         nil];   
    graphicSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"McDonalds.png"]; 
    graphic = [AGSGraphic graphicWithGeometry:graphicPoint symbol:graphicSymbol attributes:graphicAttributes infoTemplateDelegate:self];   
    [self.graphicsLayer addGraphic:graphic];
0 Kudos
TomHicks
New Contributor II
Problem solved!  I had lat/lon reversed...was using lat for x and lon for y...
0 Kudos