获取当前位置 并添加大头针

-(void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation {

    BMKCoordinateRegion region;

    region.center.latitude = userLocation.location.coordinate.latitude;

    region.center.longitude = userLocation.location.coordinate.longitude;

    region.span.latitudeDelta = 0.2;

    region.span.longitudeDelta = 0.2;

    if  (_mapView) {

        _mapView.region = region;

    }

    [_mapView setZoomLevel:19.0];

    [_locService stopUserLocationService];//定位完成停止位置更新

    //添加当前位置的标注

    CLLocationCoordinate2D coord;

    coord.latitude = userLocation.location.coordinate.latitude;

    coord.longitude = userLocation.location.coordinate.longitude;

    BMKPointAnnotation *_pointAnnotation = [[BMKPointAnnotation alloc] init];

    _pointAnnotation.coordinate = coord;

    CLLocationCoordinate2D pt=(CLLocationCoordinate2D){0,0};

    pt=(CLLocationCoordinate2D){coord.latitude,coord.longitude};

    dispatch_async(dispatch_get_main_queue(), ^{

        [_mapView removeOverlays:_mapView.overlays];    

        [_mapView setCenterCoordinate:coord animated:true];

        [_mapView addAnnotation:_pointAnnotation];

    });

}

你可能感兴趣的:(获取当前位置 并添加大头针)