apfister-esristaff

FeatureLayer initWithJson

Discussion created by apfister-esristaff Employee on Mar 15, 2011
Latest reply on Mar 17, 2011 by apfister-esristaff
I'm trying to build a feature layer using a JSON string but there is no point showing on the simulator when I run the project. Am I going about it the correct way?

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *serviceUrl = [NSURL URLWithString:kMapServiceURL];
    AGSTiledMapServiceLayer *tiledMapServiceLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:serviceUrl];
    [self.mapView addMapLayer:tiledMapServiceLayer withName:@"World Street Map"];
    
    //test FL w/ JSON
    NSString *featureCollection = @"{\"layerDefinition\": { \"geometryType\": \"esriGeometryPoint\"  }, \"featureSet\": { \"features\": [ { \"attributes\": { \"key\": \"someValue\"}, \"geometry\": {\"x\":-122.408951,\"y\":37.783206,\"spatialReference\":{\"wkid\":4326}}  } ] } }";
    
    SBJsonParser *parser = [[SBJsonParser alloc] init];
    NSDictionary *json = [parser objectWithString:featureCollection];
    
    AGSFeatureLayer *featureLayer = [[AGSFeatureLayer alloc] initWithJSON:json];
    
    [self.mapView addMapLayer:featureLayer withName:@"FL"];
 
}


Thanks,
Adam

Outcomes