想要在用户的移动路线上点汽车/自行车,在地图中使用 mapkit 和核心位置。怎么可能?是否可以通过查找谷歌地图的方向程度?如果是,那么它的数学公式是什么?
我已经尝试了 CLLocation 的课程属性,但始终给出 -1 值,这表明方向无效。
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *AnnotationViewID = @"annotationViewID";
annotationView = (MKAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if (annotationView == nil)
{
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
}
annotationView.image = [UIImage imageNamed:@"Bike.png"];
annotationView.transform = CGAffineTransformMakeRotation(45);
return annotationView;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (newLocation.horizontalAccuracy < 0)
return;
if (!newLocation)
return;
currentLocation = newLocation;
previousLocation = oldLocation;
if(currentLocation != nil)
{
if (myAnnotation)
{
[self.myMapView removeAnnotation:myAnnotation];
}
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
myAnnotation = [[MyAnnotation alloc] initWithCoordinates:location title:@"Current Location" subTitle:nil];
[self.myMapView addAnnotation:myAnnotation];
}
}