Change the style of a RouteView

Change the color and width of a RouteView dynamically.

#import "RouteViewStyle.h"
#import "SamplesMessage.h"
@import Wrld;
@import WrldWidgets;

@interface RouteViewStyle() <WRLDMapViewDelegate>

@property (nonatomic) WRLDMapView *mapView;
@property (nonatomic) NSMutableArray *m_routeViews;
@property (nonatomic) WRLDIndoorControlView *indoorControlView;

@end


@implementation RouteViewStyle
{
    NSTimer *myTimer;
    BOOL styleToggle;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _mapView = [[WRLDMapView alloc] initWithFrame:self.view.bounds];
    
    _mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _mapView.delegate = self;

    [_mapView setCenterCoordinate:CLLocationCoordinate2DMake(56.461062, -2.97977)
                        zoomLevel:17
                         animated:NO];
    
    [self.view addSubview:_mapView];
    _indoorControlView = [[WRLDIndoorControlView alloc] initWithFrame:self.view.bounds];
    
    [_indoorControlView setMapView:_mapView];
    
    [self.view addSubview:_indoorControlView];
    
    WRLDRoutingService* wrldRoutingService = [_mapView createRoutingService];
    
    WRLDRoutingQueryOptions* wrldRoutingQueryOptions = [[WRLDRoutingQueryOptions alloc] init];
    [wrldRoutingQueryOptions addIndoorWaypoint:CLLocationCoordinate2DMake(56.461231653264029, -2.983122836389253) forIndoorFloor:2];
    [wrldRoutingQueryOptions addIndoorWaypoint:CLLocationCoordinate2DMake(56.4600344, -2.9783117) forIndoorFloor:2];
    [wrldRoutingService findRoutes:(wrldRoutingQueryOptions)];
    
    _m_routeViews = [[NSMutableArray alloc] init];
    
    myTimer = [NSTimer scheduledTimerWithTimeInterval:2
                                               target:self
                                             selector:@selector(toggleStyle:)
                                             userInfo:_m_routeViews
                                              repeats:YES];
}

- (void)mapView:(WRLDMapView *)mapView routingQueryDidComplete:(int)routingQueryId routingQueryResponse:(WRLDRoutingQueryResponse *)routingQueryResponse
{
    if (routingQueryResponse.succeeded && [[routingQueryResponse results] count] > 0)
    {
        for (WRLDRoute* route in routingQueryResponse.results)
        {
            WRLDRouteViewOptions* options = [[[WRLDRouteViewOptions alloc] init] color:[[UIColor blueColor]colorWithAlphaComponent:0.5]];
            WRLDRouteView* routeView = [[WRLDRouteView alloc] initWithMapView:mapView route:route options:options];
            [_m_routeViews addObject:(routeView)];
            
        }
        
        [SamplesMessage showWithMessage:@"Found routes." andDuration:[[NSNumber alloc] initWithInt: 8]];
    }
    else
    {
        [SamplesMessage showWithMessage:@"Routing query failed." andDuration:[[NSNumber alloc] initWithInt: 8]];
    }
}

- (void)toggleStyle:(NSTimer *)timer
{
    NSMutableArray* routeViews = timer.userInfo;
    styleToggle = !styleToggle;
    UIColor* color = styleToggle ? [[UIColor whiteColor] colorWithAlphaComponent:0.5] : [[UIColor blueColor] colorWithAlphaComponent:0.5];
    CGFloat width = styleToggle ? 5.f : 10.f;
    for (WRLDRouteView* routeView in routeViews)
    {
        [routeView setColor:color];
        [routeView setWidth:width];
    }
}

@end
v0.0.1600