想要使用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];
}
}
答案 0 :(得分:-1)
我参与了一个名为“JogBuddy”的类似宠物项目。它并不完美但你可以肯定地检查出来: