Ios 使用RMShape和RMMapView生成路径

Ios 使用RMShape和RMMapView生成路径,ios,map,path,annotations,mapbox,Ios,Map,Path,Annotations,Mapbox,我正在使用mapbox sdk实现地图应用程序。我需要显示标记和路径一起,我谷歌周围,但仍然没有得到这样做的主要想法 到目前为止我已经做了 - (RMMapLayer *)mapView:(RMMapView *)aMapView layerForAnnotation:(RMAnnotation *)annotation { RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"pin-blue.p

我正在使用mapbox sdk实现地图应用程序。我需要显示标记和路径一起,我谷歌周围,但仍然没有得到这样做的主要想法

到目前为止我已经做了

- (RMMapLayer *)mapView:(RMMapView *)aMapView layerForAnnotation:(RMAnnotation *)annotation {

RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"pin-blue.png"]];
if ([annotation isKindOfClass:[MyAnnotation class]]) {
    if ([annotation.annotationType isEqualToString:@"marker"]) {
        [marker replaceUIImage:[self imageWithImage:[UIImage imageNamed:@"ic_marker.png"] scaledToSize:CGSizeMake(32, 48)]];
        [marker setAnchorPoint:CGPointMake(0.5, 1)];
        return marker;
    } else if ([annotation.annotationType isEqualToString:@"path"]) {
        path.lineWidth = 3;
        for (int i=0; i<[myCoordinateArray count]; i++) {
            NSLog(@"my coord count : %d", [myCoordinateArray count]);
            CLLocationCoordinate2D myLoc = [[myCoordinateArray objectAtIndex:i] coordinate];
            if (i>0) {
                [path addLineToCoordinate:myLoc];
            } else {
                [path moveToCoordinate:myLoc];
            }
        }
        [path closePath];
        return path;
    }
} 
return nil;
我做错了什么,还是错过了什么?请帮忙。
提前感谢。

首先,在第二个代码块中,您不需要调用
setMapView:
setNeedsDisplay


第二,什么是不可行的?代码看起来应该可以工作,并在地图上显示点和路径

谢谢你,现在我可以让它工作了。我只是错过了一些我不知道的事情。无论如何,非常感谢。@majorl3oat您能更新您的问题以反映您遗漏了什么吗?我目前面临着同样的问题,似乎无法解决它!Thanks@Priest真的很抱歉,这是很久以前的事了,我不记得我是怎么解决的。现在我被转移到另一个项目中。@prist,如果你解决了这个问题,请分享它xD@NilsHolgerson实际上,我最后做的是浏览MapBox代码,修改它们已经子类化的MapView类。整个过程非常麻烦,我们最终不得不一起放弃这个想法:\
myPin = [[MyAnnotation alloc] init];
        [myPin setMapView:mapView];

        [myPin setCoordinate:myLatLng];
        [myPin setTitle:@"Marker"];

        myPin.annotationType = @"marker";
        [mapView addAnnotation:myPin];
        [mapView setNeedsDisplay];

myPath = [[MyAnnotation alloc] init];
        [myPath setCoordinate:myLatLng];
        myPath.annotationType = @"path";
        [mapView addAnnotation:myPath];