iOS 硬件 地图-基础-自定义追踪

来源:互联网 发布:郑州软件 编辑:程序博客网 时间:2024/06/04 19:54
  • (void)mapView:(MKMapView )mapView didUpdateUserLocation:(MKUserLocation )userLocation{

    userLocation.title = @”我的位置”;

    userLocation.subtitle = @”my location”;

    //设置中心
    [self.mapView setCenterCoordinate:userLocation.location.coordinate animated:YES];

    //设置范围
    /*
    typedef struct {
    CLLocationCoordinate2D center;
    MKCoordinateSpan span;
    } MKCoordinateRegion;
    */

    /*
    typedef struct {
    CLLocationDegrees latitudeDelta;
    CLLocationDegrees longitudeDelta;
    } MKCoordinateSpan;
    */

    MKCoordinateSpan span = MKCoordinateSpanMake(0.735144, 0.546570);

    MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.location.coordinate, span);

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

}

//==================求出 经纬度的跨度

  • (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{

    NSLog(@”%f”,self.mapView.region.span.latitudeDelta);

    NSLog(@”%f”,self.mapView.region.span.longitudeDelta);
    }

0 0
原创粉丝点击