我使用 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;
}
//添加注解
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];
我做错了什么,还是我错过了什么?请帮忙。提前致谢。