手机位置服务,导航 typedef struct { CLLocationDegrees latitudeDelta; CLLocationDegrees longitudeDelta; } MKCoordinateSpan ; typedef struct{ CLLocationCoordinate2D center; MKCoordinateSpan span; }MKCoordinateRegion; du CLLocationCoordinate2D center; center.latitude=40.029915; center.longitude=116.347082; MKCoordinateSpan
regionDidChangeAnimated:(BOOL)animated { MKCoordinateRegion region = mapView.region; // 经纬度跨度 MKCoordinateSpan 是一个用来表示区域的结构体,定义如下 typedef struct { CLLocationCoordinate2D center; // 区域的中心点位置 MKCoordinateSpan span; // 区域的跨度 } MKCoordinateRegion; //MKCoordinateSpan的定义 typedef struct { CLLocationDegrees latitudeDelta ; // 纬度跨度 CLLocationDegrees longitudeDelta; // 经度跨度 } MKCoordinateSpan; 例:回到当前位置 // 1.拿到用户的经纬度 可以在地图的区域改变完成时调用 - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; */ MKCoordinateSpan
region结构体如下: typedef struct { CLLocationCoordinate2D center;//地图中心的经纬度 MKCoordinateSpan span; CLLocationDegrees latitude;//纬度,北纬为正,南纬为负 CLLocationDegrees longitude;//经度,东经为正,西经为负 } CLLocationCoordinate2D; MKCoordinateSpan typedef struct { CLLocationDegrees latitudeDelta;//纬度范围 CLLocationDegrees longitudeDelta;//经度范围 } MKCoordinateSpan 注意:MKCoordinateSpan的显示范围是取决于大的一边的,比如如果我们这样写: MKCoordinateSpanMake(1.8, 360); 最后依然会显示整个世界地图。
CLLocation *location = userLocation.location; //设置地图显示的“区域” //跨度,通过这个精细控制显示的地图视角 MKCoordinateSpan userLocation{ CLLocation *location = userLocation.location; //设置地图显示的“区域” //跨度 MKCoordinateSpan
10 11 //显示经纬度 12 [self mapPoint:coordinate]; 13 14 15 //标记范围 16 MKCoordinateSpan
span(MKCoordinateSpan)定义了指定中央点(point)的map能显示多少内容以及比例尺。
CLLocation *newLocation = locations.lastObject; self.userCoordinate = newLocation.coordinate; MKCoordinateSpan followUserLoc = NO; } } #pragma mark - 聚焦到... - (void)focusMapTo:(CLLocationCoordinate2D)coordinate { MKCoordinateSpan
MKCoordinateRegion region; MKCoordinateRegion 区域结构体包含 CLLocationCoordinate2D 经纬度( latitude 纬度, longitude 经度) MKCoordinateSpan 显示跨度 1度 ~111千米 MKCoordinateSpan span = MKCoordinateSpanMake(0.021256, 0.016093); //3. MKLaunchOptionsShowsTrafficKey 4、中心点坐标,CLLocationCoordinate2D类型 MKLaunchOptionsMapCenterKey 5、地图显示跨度,MKCoordinateSpan
double longitudeSpan = fabs(self.longitude - self.userLocation.coordinate.longitude) *3; MKCoordinateSpan _mapView.showsUserLocation = YES; _mapView.delegate = self; //初始位置及显示范围 MKCoordinateSpan
CLLocationCoordinate2D( latitude: 34.011286, longitude: -116.166868) let span = MKCoordinateSpan