tags:

views:

8

answers:

0

Hi,

I am trying to make a map where I can look up locations, and put multiple pins on the map. and when I want to look up other locations I want to remove all the old pins.

this is my code:

-(void)addPins:(GeocodeLocation*) location
{
 CLLocationCoordinate2D locatie;
 locatie.latitude = location.lat;
 locatie.longitude = location.lon;
 cPlacemark= [[CustomPlacemark alloc] initWithCoordinate:locatie];
 cPlacemark.title = selected;

 if(location.city != nil && location.city != selected){
  cPlacemark.subtitle = [NSString stringWithFormat:@"%@", location.city]; 
 }else if (location.locality != nil && location.locality != selected) 
 {
  cPlacemark.subtitle = [NSString stringWithFormat:@"%@", location.locality];  
 }else if(location.province != nil && location.province != selected)
 {
  cPlacemark.subtitle = [NSString stringWithFormat:@"%@", location.province];   
 }else
 {
  cPlacemark.subtitle = nil; 
 }

 [pinPlacemark addObject:cPlacemark];
 pins = [pinPlacemark copy];

 [map addAnnotations:pins];
 [mLocationManager stopUpdatingLocation];
}

and somewhere else I want to remove the annotation: [map removeAnnotations:pins];

but nothing happens.. no pins are added and of course no pins are removed

Can someone help me please? I'm stuck on this for a day already

thanks in advance