Search code examples
iosobjective-cmkmapviewmkplacemark

iOS: How will I drop a placemark at user's location?


This is my code to recenter map to user's location in iOS. This method works fine, but the problem I am having is dropping a placemark on the user's current location. I am new to using placemark and will appreciate it if someone help me out.

- (IBAction)recenterMapToUserLocation:(id)sender {
MKCoordinateRegion region;
MKCoordinateSpan span;

span.latitudeDelta = 0.02;
span.longitudeDelta = 0.02;

region.span = span;
region.center = self.mapView.userLocation.coordinate;

[self.mapView setRegion:region animated:YES];
}

Solution

  • To drop a pin on the user's location, all you have to do is tell the mapView to show the user's location:

    [self.mapView setShowsUserLocation:YES];
    

    That should do it!