Refresh my mapView
-
19-09-2019 - |
Question
i have a mapView with pins on it, and the following code for CLLocation and getDistance between me and another points on the map:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
Koordinate *kunde = [[Koordinate alloc] init];
kundenPoints = [[NSMutableArray array] retain];
for(int i = 0; i<[eventPoints count]; i++){
kunde = [eventPoints objectAtIndex:i];
CLLocation *userLoc = [[CLLocation alloc] initWithLatitude:kunde.latitude longitude:kunde.longtitude];
double distance = [newLocation getDistanceFrom:userLoc] / 1000;
if(distance <= 100){
[kundenPoints addObject:kunde];
}else {
}
}
[mapView addAnnotations:kundenPoints];
}
but how can i implement a method that refreshes the map when i tab on a button? that i always get the pins around me when i want. the button is not the problem, only the refresh!
i hope someone could help me??
best regards Marco
Solution
as far as I know there is no such a thing as removeAllAnnotations, at least not in iOS4 SDK... although you can quickly fix it using
NSArray *ants = [mapView_ annotations];
[mapView_ removeAnnotations:ants];
same goes for overlays
NSArray *ants = [mapView_ overlays];
[mapView_ removeOverlays:ants];
so far is the best way I've found to do it.
OTHER TIPS
Just removeAllAnnotations
to your mapView and add the new ones, this will refresh the annotations on your map.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow