如何在ios MKMapView中设置标记

时间:2014-04-16 10:38:46

标签: ios mkmapview

如何在MKMapView中设置标记 这是我设置纬度和经度的代码,但我不知道如何设置标记 请给我解决方案。

    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];

1 个答案:

答案 0 :(得分:0)

有用的教程: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];