I am adding MKPointAnnotation
annotation using MKMapView.
I have given image to MKPointAnnoation but blue dot is not removed.
-(void)updateMarkerWithUserLocation
{
NSString *name= [[NSUserDefaults standardUserDefaults]valueForKey:@"userName"];
for (MKPointAnnotation *annotation in _mapView.annotations)
{
[_mapView removeAnnotation:annotation];
}
NSNumber * latitude = [NSNumber numberWithFloat:[[NSUserDefaults standardUserDefaults]floatForKey:@"currentLatitude"]];
NSNumber * longitude = [NSNumber numberWithFloat:[[NSUserDefaults standardUserDefaults]floatForKey:@"currentLongitude"]];
////****** to add my location in the map of type MKPointAnnotation
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = [latitude floatValue];
annotationCoord.longitude = [longitude floatValue];
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = annotationCoord;
StrLocality=[[NSUserDefaults standardUserDefaults]valueForKey:@"StrLocality"];
annotationPoint.title = name;
annotationPoint.subtitle=StrLocality;
[_mapView addAnnotation:annotationPoint];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
// Try to dequeue an existing pin view first.
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"CustomPinAnnotationView"];
if (!pinView)
{
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotationView"];
//pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:@"user_location.png"];
// pinView.calloutOffset = CGPointMake(5, 32);
} else {
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}