Trying to add a custom pin for current location, However the location does not update. Even after setting setShowsUserLocation = YES;
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
if ([[annotation title] isEqualToString:@"Current Location"]) {
self.image = [UIImage imageNamed:[NSString stringWithFormat:@"cursor_%i.png", [[Session instance].current_option cursorValue]+1]];
}
However, if I set to return nil;
everything works fine, but I lose the custom image. I really want to get this to work. Any help would be greatly appreciated.
As you've seen the setShowsUserLocation flag only shows the current location using the default blue bubble.
What you need to do here listen for location updates from the phone and manually reposition your annotation yourself. You can do this by creating a CLLocationManager instance and remove and replace your annotation whenever the Location Manager notifies its delegate of an update:
To reposition the coordinates, I have a class, Placemark, that conforms to the protocol MKAnnotation:
Then in my mapview controller I place the annotation with: