문제

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];
도움이 되었습니까?

해결책

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top