AddFeature in AGSFeatureLayer

861
1
12-10-2012 10:34 PM
winnieliu
New Contributor
I'm trying to add a new feature on the map
I have already build geometry and graphic, and i sure that graphic has got all the info
But i still can't get a new feature on the map

here is the cade , hope there has someone can help me fix the problem.

    
    AGSPictureMarkerSymbol *pt=[AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"ArcGIS.bundle/GpsDisplay.png"];    
    double lon = [[self.lonTextField text] doubleValue];
    double lat = [[self.latTextField text] doubleValue];
    
    AGSPoint * newpoint2 = [AGSPoint pointWithX:lon y:lat spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326 WKT:nil]];
    
    NSMutableDictionary *dic2 = [[NSMutableDictionary alloc] init];
    [dic2 setObject:self.typeTextField.text forKey:@"req_type"];
    [dic2 setObject:self.dateTextField.text forKey:@"req_date"];
    [dic2 setObject:self.timeTextField.text forKey:@"req_time"];
    [dic2 setObject:self.desTextView.text forKey:@"des"];
    [dic2 setObject:self.titleTextView.text forKey:@"title"];   
    [dic2 setObject:self.lonTextField.text forKey:@"x_coord"];
    [dic2 setObject:self.latTextField.text forKey:@"y_coord"];
    
    AGSGraphic * graphic=[[AGSGraphic alloc]initWithGeometry:newpoint2 symbol:pt attributes:dic2 infoTemplateDelegate:nil];
            
    graphic.attributes = dic2;
     
    //update the service 
    [ev.activeFeatureLayer addFeatures:[NSArray arrayWithObject:graphic]];
0 Kudos
1 Reply
NimeshJarecha
Esri Regular Contributor
What is the spatial reference of the map? What is the spatial reference of feature layer? Is that matching with geometry you are creating with 4326 spatial reference?

Regards,
Nimesh
0 Kudos