不推荐使用 RMPath,请尝试改用 RMShape。也不要忘记在将注释添加到地图之前设置它的边界框(setBoundingBoxFromLocations 可能很有用)。
例子 :
pathAnnotation = [[RMAnnotation alloc]initWithMapView:mapView coordinate:CLLocationCoordinate2DMake(long,lat) andTitle:@"path"];
[pathAnnotation setBoundingBoxFromLocations:pathLocations];
然后在你的 layerForAnnotation() 中:
RMShape *path = [[RMShape alloc] initWithView:mapView] ;
[path setLineColor:[UIColor colorWithRed:0.2 green:0.7 blue:1 alpha:0.7]];
[path setLineWidth:4];
// Create real coordinates from data
for(int idx = 0; idx < pathPoints.count; idx++)
{
CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(pathPoints[idx].latitude,pathPoints[idx].longitude);
// First point
if( idx == 0){
[path moveToCoordinate:coord];
}else{
[path addLineToCoordinate:coord];
}
}
return path;