我是新來使用RMPolylines和RMShapes和我認爲我正確地執行這個代碼,但沒有什麼是地圖上顯示了:的iOS MapBox RMShape
RMMapBoxSource *tilesource = [[RMMapBoxSource alloc] initWithMapID:kMapID];
[mapView setTileSource:tilesource];
NSArray *locations = [NSArray arrayWithObjects:[[CLLocation alloc] initWithLatitude:-33.981595 longitude:151.072900],[[CLLocation alloc] initWithLatitude:-33.981560 longitude:151.073544],[[CLLocation alloc] initWithLatitude:-33.981560 longitude:151.073845],[[CLLocation alloc] initWithLatitude:-33.981666 longitude:151.074016], nil];
RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations objectAtIndex:0]).coordinate andTitle:@"Hola biatches!"];
annoation43.userInfo = locations;
[annoation43 setBoundingBoxFromLocations:locations];
[mapView addAnnotation:annoation43];
-(RMMapLayer *)mapView:(RMMapView *)mapViewer layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
RMShape *shape = [[RMShape alloc] initWithView:mapView];
shape.lineColor = [UIColor orangeColor];
shape.lineWidth = 5.0;
for (CLLocation *location in (NSArray *)annotation.userInfo)
[shape addLineToCoordinate:location.coordinate];
return shape;
NSLog(@"It is working Dora!");
}
因此,我認爲我做錯了這裏,但我無法挑選 - 如果需要更多代碼或信息,請告訴我。
是的,你肯定會需要一個委託集來使用'-mapView:layerForAnnotation:'委託方法。 – incanus