Authored by Obrand69

Added method for retrieving all markers

Added method for removing a specific marker
added sample code in MapViewViewController
... ... @@ -46,6 +46,28 @@
NSLog(@"marker added to %f %f", loc.origin.x, loc.origin.y);*/
[mapView addDefaultMarkerAt:[[mapView contents] mapCenter]];
NSArray *markers = [mapView getMarkers];
NSLog(@"Nb markers %d", [markers count]);
NSEnumerator *markerEnumerator = [markers objectEnumerator];
RMMarker *aMarker;
while (aMarker = (RMMarker *)[markerEnumerator nextObject])
{
RMXYPoint point = [aMarker location];
NSLog(@"Marker location: X:%d, Y:%d", point.x, point.y);
[mapView removeMarker:aMarker];
}
// Put the marker back
[mapView addDefaultMarkerAt:[[mapView contents] mapCenter]];
}
... ...
... ... @@ -118,5 +118,7 @@ enum {
- (void) addMarker: (RMMarker*)marker AtLatLong:(CLLocationCoordinate2D)point;
- (void) addDefaultMarkerAt: (CLLocationCoordinate2D)point;
- (void) removeMarkers;
- (NSArray *)getMarkers;
- (void) removeMarker:(RMMarker *)marker;
@end
... ...
... ... @@ -564,4 +564,14 @@ static BOOL _performExpensiveOperations = YES;
overlay.sublayers = [NSArray arrayWithObjects:nil];
}
- (NSArray *)getMarkers
{
return [overlay sublayers];
}
- (void) removeMarker:(RMMarker *)marker
{
[marker removeFromSuperlayer];
}
@end
... ...
... ... @@ -61,5 +61,7 @@ typedef struct {
- (void) addMarker: (RMMarker*)marker AtLatLong:(CLLocationCoordinate2D)point;
- (void) addDefaultMarkerAt: (CLLocationCoordinate2D)point;
- (void) removeMarkers;
- (NSArray *) getMarkers;
- (void) removeMarker:(RMMarker *)marker;
@end
... ...
... ... @@ -344,4 +344,14 @@
[contents removeMarkers];
}
- (NSArray *) getMarkers
{
return [contents getMarkers];
}
- (void) removeMarker: (RMMarker *)marker
{
[contents removeMarker:marker];
}
@end
... ...