How to change the color of the route in Skobbler

2020-03-30 03:34发布

问题:

Hello i want to change the color of the routes in skobbler.For example im doing a waze like app in android. i want to change the color of the route to red when there is a heavy traffic in the route. maybe someone can help me on this. Thanks in advance.

回答1:

Currently the appearance of routes (the main route and the alternates) can be styled by editing the style JSON files that can be found in the SKMaps.zip archive that stores the resources. In the demo these JSON files are daystyle.json, grayscalestyle.json, nightstyle.json and outdoorstyle.json.

Here you can find a modified daystyle.json file in which the route colors have been changed. Look for comments ("//") in this file to find out which properties were modified in order to change route colors. Similar changes in the other JSON style files should be made in order to modify route colors for the rest of the map styles.

For the moment changing the route color dynamically or styling route segments differently is not currently supported in the SDK.

Alternative approach:

  • not colouring the route but colouring various road segments along the route, provided that you draw them separately. Retrieve the route information by calling routeCoordinatesForRouteWithId

    NSArray *locations = [[SKRoutingService sharedInstance] routeCoordinatesForRouteWithId:routeInformation.routeID];

Note: make sure you have set requestExtendedRoutePointsInfo to true for SKRouteSetttings before calling calculate route. And then you'll have access to the road segments, which you can draw on the map as colored Polylines.