In my app i add array of AGSFeatureLayer with function:
for(int i=0;i<[self.nome count];i++){
NSString *url = [NSString stringWithFormat:@"%@/%i",servizio, i];
self.ServizioSITR = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:url] mode:AGSFeatureLayerModeSnapshot];
[self.mapView addMapLayer:self.ServizioSITR withName:[self.nome objectAtIndex:i]];
}
I can not remove with function:
for(int i=0;i<[self.nome count];i++){
[self.mapView removeMapLayerWithName:[self.nome objectAtIndex:i]];
}
WHYYYYYYYYYYYY?
Please Help me
I would make 2 changes in your code.
for(int i=0;i<[self.nome count];i++){
NSString *url = [NSString stringWithFormat:@"%@/%i",servizio, i];
AGSFeatureLayer *local = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:url] mode:AGSFeatureLayerModeSnapshot];
[self.mapView addMapLayer:local withName:[self.nomeobjectAtIndex:i]];
}
Then I would let them all load before calling the method to remove them by name, as what I think is happening, you call remove layer with name and hasn't been loaded yet.
Let me know if that makes any difference.
Cheers
Al