Полилиния MapBox не отображается на карте

У меня возникла проблема при попытке добавить полилинию на карту. Я получаю маршруты от MKDirections и создаю RMPolylineAnnotation, но она не отображается на карте.
Как я вижу, следующий метод вызывается только один раз при появлении карты:

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

Вот код, который я использую:

- (void)getRoute {
CLLocation *source = [[CLLocation alloc] initWithLatitude:self.mapView.userLocation.coordinate.latitude longitude:self.mapView.userLocation.coordinate.longitude];

CLLocation *destination = [[CLLocation alloc] initWithLatitude:self.mapView.selectedAnnotation.coordinate.latitude longitude:self.mapView.selectedAnnotation.coordinate.longitude];

[AppleDirectionManager getDirectionsFromPoint:source toPoint:destination transportType:MKDirectionsTransportTypeAutomobile withCompletion:^(MKDirectionsResponse *result) {

    self.routeStepsArray = [[result.routes firstObject] steps];
    for (MKRoute *route in result.routes) {
        NSMutableArray *points = [NSMutableArray array];
        for (int i = 0; i < route.polyline.pointCount; i++) {
            MKMapPoint point = route.polyline.points[i];

            CLLocation *location = [[CLLocation alloc] initWithLatitude:point.x longitude:point.y];
            [points addObject:location];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            NSArray *arr = [points copy];
            RMPolylineAnnotation *polyline = [[RMPolylineAnnotation alloc] initWithMapView:self.mapView points:arr];
            [self.mapView addAnnotation:polyline];
        });
    }
}];
}

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

if (annotation.isUserLocationAnnotation)
    return nil;

RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"blabla.png"]];

[marker setCanShowCallout:YES];

[marker setName:@"blabla"];

return marker;

}

Также я не могу показать пользовательскую выноску для RMPointAnnotation.


person user3519266    schedule 10.04.2014    source источник
comment
можете ли вы сделать свой вопрос (особенно в заголовке - вы имели в виду «не» вместо «сейчас» более ясно и указать, что вы пробовали?   -  person Martin Serrano    schedule 10.04.2014


Ответы (1)


Для RMPointAnnotation это легко.

 _polylineAnnotation = [[RMPolylineAnnotation alloc] initWithMapView:_mapView points:@[Location,Location]];
 _polylineAnnotation.lineColor = [UIColor redColor];
 _polylineAnnotation.lineWidth = 10.0f;
 [_mapView addAnnotation:_polylineAnnotation];
person Iraklii    schedule 24.04.2014
comment
Я тоже так пользуюсь, а на карте почему-то не отображается - person user3519266; 23.06.2014