2
我想添加注释到地图上2个位置之间的路线。该注释就像Google Map中的复选标记。我使用MKPolyline绘制了路线。现在添加几个注释,我应该怎么做?在iPhone中的地图中添加路线注释
是新手。所以请不要介意我问这个问题。
在此先感谢。
我想添加注释到地图上2个位置之间的路线。该注释就像Google Map中的复选标记。我使用MKPolyline绘制了路线。现在添加几个注释,我应该怎么做?在iPhone中的地图中添加路线注释
是新手。所以请不要介意我问这个问题。
在此先感谢。
因为,我认为这是一个很好的问题,许多人都面临这个问题,我正在回答。 我们需要实现的MKAnnotationView
此委托方法..
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
而且我们需要所有的注释中是这样的路线数组..
self.mRouteArray = [mDirections routeArray];
NSArray *_routeWayPoints1 = [[mRouteArray objectAtIndex:0] wayPoints];
NSArray *mPlacetitles = [[mRouteArray objectAtIndex:0] mPlaceTitle];
for(int idx = 0; idx < [_routeWayPoints1 count]; idx++)
{
mBetweenAnnotation = [[SBRouteAnnotation alloc] initWithCoordinate:[[_routeWayPoints1 objectAtIndex:idx]coordinate]
title:[mPlacetitles objectAtIndex:idx]
annotationType:SBRouteAnnotationTypeWayPoint];
[self.mAnnotations addObject:mBetweenAnnotation];
[mBetweenAnnotation release];
}
这将加载所有注释之间的路线。 可能这会帮助他人.. 快乐编码...