AGSGraphicsLayer with manual added graphics, all graphics are located at 0,0

Discussion created by nijkampr on Sep 20, 2011
Latest reply on Sep 20, 2011 by nijkampr
Hi all,

I retrieve some data from a webserver, through JSON. This works flawless.
In this data is the latitude, longitude and a name.

I want to add this data to my mapview, i've added a AGSGraphicsLayer to do this.

I add the graphics layer with the following code:

    self.trackLayer = [AGSGraphicsLayer graphicsLayer];
    [self.mapView addMapLayer:self.trackLayer withName:@"trackLayer"];

This works. As expected.

When i push a button the data is received, and added to the map:

    NSArray *locations = [_locationService getLocations];
    for (NSDictionary* loc in locations) {
        NSLog(@"%@", loc);
        float lat = [[loc objectForKey:@"lat"] floatValue];
        float lon = [[loc objectForKey:@"lon"] floatValue];
        AGSSimpleMarkerSymbol *pointMarker = [AGSSimpleMarkerSymbol simpleMarkerSymbolWithColor:[UIColor redColor]];
        pointMarker.size = 10.00; = AGSSimpleMarkerSymbolStyleCircle;    

        AGSPoint *point = [AGSPoint pointWithX:lat y:lon spatialReference:self.mapView.spatialReference];

        AGSGraphic *location = [[AGSGraphic alloc] initWithGeometry:point symbol:pointMarker attributes:Nil infoTemplateDelegate:Nil];
        NSLog(@"%@", location);
        [_trackLayer addGraphic:location];
   [_trackLayer dataChanged];

The NSLog produces the following:
geometry: AGSPoint: x = 52.322800, y = 4.879720, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null], symbol: { AGSSimpleMarkerSymbol: style: esriSMSCircle, size: 10.000000, outline: <AGSSimpleLineSymbol: 0x8c0b50> }, attributes: (null)

When i print the description of the geometry within the Graphics layer:
AGSPoint: x = 52.317799, y = 4.879200, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null]

So, the coordinates are in the point. For all the testdata. But they are still shown at 0,0!
Whats wrong here? The only thing i saw was that the renderer and initialEnvelope  of the GraphicsLayer is 0x0...

Many thanks!