JSON
server, but I wanted to check if annotation is already on the map, if so, do not add it again . For they are being added one over the other. Can someone help me solve this problem?
My code adding the pins :
// adiciona produtos ao mapa
- (void)adicionaAnnotationsNoMapa:(id)objetos{
NSMutableArray *annotationsPins = [[NSMutableArray alloc] init];
for (NSDictionary *annotationDeProdutos in objetos) {
CLLocationCoordinate2D location;
AnnotationMap *myAnn;
myAnn = [[AnnotationMap alloc] init];
location.latitude = [[annotationDeProdutos objectForKey:@"latitude"] floatValue];
location.longitude = [[annotationDeProdutos objectForKey:@"longitude"] floatValue];
myAnn.coordinate = location;
myAnn.title = [annotationDeProdutos objectForKey:@"name"];
myAnn.subtitle = [NSString stringWithFormat:@"R$ %@",[annotationDeProdutos objectForKey:@"price"]];
myAnn.categoria = [NSString stringWithFormat:@"%@", [annotationDeProdutos objectForKey:@"id_categoria"]];
myAnn.idProduto = [NSString stringWithFormat:@"%@", [annotationDeProdutos objectForKey:@"id"]];
[annotationsPins addObject:myAnn];
}
[self.mapView addAnnotations:annotationsPins];
}