-4

How to set marker in MKMapView Here is my code to set a latitude and longitude but i dont know how to set marker please give me solution.

    CLLocationCoordinate2D center;
    center.latitude = latitude;
    center.longitude = longitude;

    CLLocationCoordinate2D location = mapView.userLocation.coordinate;
    MKCoordinateRegion region;
    MKCoordinateSpan span;

    location.latitude  = center.latitude;  //37.250556;
    location.longitude = center.longitude; //-96.358333;

    span.latitudeDelta = 0.05;
    span.longitudeDelta = 0.05;

    region.span = span;
    region.center = location;

    [mapView setRegion:region animated:YES];
    [mapView regionThatFits:region];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • marker means pin annotation ? – Rushabh Apr 16 '14 at 10:39
  • 2
    This question is a duplicate and shows no research effort. http://stackoverflow.com/questions/2878758/iphone-create-mkannotation?lq=1 http://stackoverflow.com/questions/5491791/how-to-add-a-map-annotation-on-mkmapview – The dude Apr 16 '14 at 10:43
  • not required duplicat pin Need only one pin in mapview – Nishant Chandwani Apr 16 '14 at 10:44
  • The dude means the question is a duplicate. It has been asked here before and you should have searched for the answer before posting this question. – Craig Apr 17 '14 at 01:07

1 Answers1

0

Useful tutorial: maybelost.com/2011/01/a-basic-mapview-and-annotation-tutorial

// Add the annotation to our map view 
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];
Jack Allen
  • 549
  • 2
  • 5
  • 19