KNMapRouteTheme
INFO
This English reference is based on Directions SDK 1.12.12. For the latest version, see the Korean reference.
- Inherits from: NSObject
- Declared in: KNMapRouteTheme.h
Sets the route style. You can set the line thickness and color of the main route and alternative routes. You can also apply traffic congestion information and distinguish colors by congestion level.
Properties
| Name | Description | Type |
|---|---|---|
lineWidth | Line thickness of the main route (default: -1) | @property (nonatomic, assign) float lineWidth |
strokeWidth | Stroke thickness of the main route (default: -1) | @property (nonatomic, assign) float strokeWidth |
lineColors | Line color of the main route. The colors represent the current traffic state: smooth, slightly congested, congested, very congested, unknown, or road closure. Set one color to display the entire line uniformly. | @property (nonatomic, assign, nonnull) KNRouteColors* lineColors |
strokeColors | Stroke color of the main route. The colors represent the current traffic state: smooth, slightly congested, congested, very congested, unknown, or road closure. Set one color to display the entire line uniformly. | @property (nonatomic, assign, nonnull) KNRouteColors* strokeColors |
alterRoute | Line and stroke thickness and color of alternative routes. Alternative routes are displayed in a single color. | @property (nonatomic, assign, nonnull) KNAlterRouteInfo* alterRoute |
isVisibleRoute | Whether the route is displayed. (default: YES) | @property (nonatomic, assign) BOOL isVisibleRoute |
isVisibleRGArrow | Whether direction arrows on the route are displayed. Mainly used to hide the arrows so that the route is easier to read on a screen showing the entire route. (default: YES) | @property (nonatomic, assign) BOOL isVisibleRGArrow |
Example code — KNMapRouteTheme Example code for using the property
objc
// Set the main route line width to 10
mapView.routeTheme.lineWidth = 10.0;
float routeLineWidth = mapView.routeTheme.lineWidth;
// Set the main route stroke width to 1
mapView.routeTheme.strokeWidth = 1.0;
float routeStrokeWidth = mapView.routeTheme.strokeWidth;
// Line color of the main route in mapView 1
KNRouteColors* routeLineColors = [KNRouteColors routeColors];
routeLineColors.normal = UIColor.blueColor; // Smooth
routeLineColors.trafficJamModerate = UIColor.yellowColor; // Slightly congested
routeLineColors.trafficJamHeavy = UIColor.orangeColor; // Congested
routeLineColors.trafficJamVeryHeavy = UIColor.redColor; // Heavily congested
routeLineColors.unknown = UIColor.grayColor; // Unknown
routeLineColors.block = UIColor.blackColor; // Restricted road
mapView.routeTheme.lineColors = routeLineColors;
// Line color of the main route in mapView 2
KNRouteColors* routeLineColors = mapView.routeTheme.lineColors
routeLineColors.normal = UIColor.yellowColor; // Smooth
routeLineColors.unknown = UIColor.grayColor; // Unknown
routeLineColors.block = UIColor.blackColor; // Restricted road
// Stroke color of the main route in mapView 1
KNRouteColors* routeStrokeColors = [KNRouteColors routeColors];
routeStrokeColors.normal = UIColor.blueColor; // Smooth
routeStrokeColors.trafficJamModerate = UIColor.yellowColor; // Slightly congested
routeStrokeColors.trafficJamHeavy = UIColor.orangeColor; // Congested
routeStrokeColors.trafficJamVeryHeavy = UIColor.redColor; // Heavily congested
routeStrokeColors.unknown = UIColor.grayColor; // Unknown
routeStrokeColors.blocked = UIColor.blackColor; // Restricted road
mapView.routeTheme.strokeColors = routeStrokeColors
// Stroke color of the main route in mapView 2
KNRouteColors* routeStrokeColors = mapView.routeTheme.strokeColors
routeStrokeColors.normal = UIColor.yellowColor; // Smooth
routeStrokeColors.unknown = UIColor.grayColor; // Unknown
routeStrokeColors.block = UIColor.blackColor; // Restricted road
// Set the line width and color of the alternative route in mapView 1
KNMapAlterRouteInfo* alterRouteStyle = [KNMapAlterRouteInfo alterRouteTheme];
alterRouteStyle.lineWidth = 10.0; // Line width
alterRouteStyle.strokeWidth = 1.0; // Stroke width
alterRouteStyle.lineColor = UIColor.grayColor; // Line color
alterRouteStyle.strokeColor = UIColor.blackColor; // Stroke color
mapView.routeTheme.alterRoute = alterRouteStyle;
// Set the line width and color of the alternative route in mapView 2
mapView.routeTheme.alterRoute.lineWidth = 10.0;
mapView.routeTheme.alterRoute.strokeColor = UIColor.blackColor;
// Hide the route
mapView.routeTheme.isVisibleRoute = false;
bool isVisibleRoute = mapView.routeTheme.isVisibleRoute;
// Hide direction arrows on the route
mapView.routeTheme.isVisibleRGArrow = false;
bool isVisibleRouteRGArrow = mapView.routeTheme.isVisibleRGArrow;Constructor
+ routeTheme
Creates a KNMapRouteTheme object initialized with predefined route colors.
objc
+(KNMapRouteTheme* _Nonnull)routeTheme+ driveDay
Creates a single-color daytime driving route theme.
objc
+(KNMapRouteTheme* _Nonnull) driveDay+ driveNight
Creates a single-color nighttime driving route theme.
objc
+(KNMapRouteTheme* _Nonnull) driveNight+ trafficDay
Creates a daytime route theme whose segment colors reflect traffic congestion.
objc
+(KNMapRouteTheme* _Nonnull) trafficDay+ trafficNight
Creates a nighttime route theme whose segment colors reflect traffic congestion.
objc
+(KNMapRouteTheme* _Nonnull) trafficNight