KNMapPolyline
INFO
This English reference is based on Directions SDK 1.12.8-hotfix02. For the latest version, see the Korean reference.
Creates a polyline to display on the map. You can configure its color, width, and line style. A polyline connects vertices specified in KATEC coordinates. To add one to the map, create a KNMapPolyline and register it with KNMapView.
Constructor
Creates a KNMapPolyline object made up of KATEC coordinates.
KNMapPolyline(points: List<FloatPoint>, lineColor: Int, lineWidth: Float, lineDashType: KNLineDashType, priority: Int)TIP
Markers always have higher display priority than other objects, such as circles and polygons. When they overlap, the marker appears on top.
Properties
| Name | Description | Type |
|---|---|---|
lineColor | Color of Polyline (default: Color.BLACK) | var lineColor: Int |
lineWidth | Thickness of polyline (default: 2, thickness setting range: 1~5) | var lineWidth: Float |
lineDashType | Type of polyline. You can set a solid, dotted, dashed, dash-dotted, or dash-double-dotted line. (default: KNLineDashType_Solid) | var lineDashType: KNLineDashType |
priority | Priority to display polyline. A higher number is displayed on top. (default: 0, priority range: 0~65535) | var priority: Int |
isVisible | Polyline display status (default: true) | var isVisible: Boolean |
tag | Tag to set in Polyline (tag).Tags have an Int value and can be used when you want to classify into categories or make separate distinctions (optional) | var tag: Int |
id (readOnly) | Unique ID of Polyline | var id: Int |
Example code — KNMapPolyline
fun createPolyLineWithMapView(): KNMapPolyline {
val center = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val pos = (KNSDK.sharedGpsManager()?.lastValidGpsData?.pos) ?: FloatPoint(321397.72f, 532790.94f)
val polygonVertex = arrayListOf<FloatPoint>()
polygonVertex.add(FloatPoint(pos.x - 100f, pos.y - 100f))
polygonVertex.add(FloatPoint(pos.x + 100f, pos.y - 100f))
polygonVertex.add(FloatPoint(pos.x + 100f, pos.y + 100f))
polygonVertex.add(FloatPoint(pos.x - 50f, pos.y + 150f))
return KNMapPolyline(polygonVertex,
lineColor = Color.YELLOW,
lineWidth = 3f,
lineDashType = KNLineDashType.KNLineDashType_Dotted,
priority = 1)
}Methods
addPoint
Adds a KATEC-coordinate vertex and connects it to the current line's last vertex.
Example code — addPoint
fun createPolyLineToAddPointWithMapView(): KNMapPolyline {
val center = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val pos = (KNSDK.sharedGpsManager()?.lastValidGpsData?.pos) ?: FloatPoint(321397.72f, 532790.94f)
val polylines = arrayListOf()
polylines.add(FloatPoint(pos.x - 100f, pos.y - 100f))
polylines.add(FloatPoint(pos.x + 100f, pos.y - 100f))
polylines.add(FloatPoint(pos.x + 100f, pos.y + 100f))
polylines.add(FloatPoint(pos.x - 50f, pos.y + 150f))
return KNMapPolyline(polylines, lineColor = Color.YELLOW,
ineWidth = 3f,
lineDashType = KNLineDashType.KNLineDashType_Dotted,
priority = 1).apply {
val addPointInfo = FloatPoint(pos.x - 50f, pos.y + 50f)
addPoint(addPointInfo)
}
}fun addPoint( point: FloatPoint )Parameters
| Name | Description |
|---|---|
point | Line vertex |
addPoints
Adds multiple KATEC-coordinate vertices and connects them to the current line's last vertex.
Example code — addPoints
fun createPolyLineToAddPointsWithMapView(): KNMapPolyline {
val pos = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val polylines = arrayListOf()
polylines.add(FloatPoint(pos.x - 100f, pos.y - 100f))
polylines.add(FloatPoint(pos.x + 100f, pos.y - 100f))
polylines.add(FloatPoint(pos.x + 100f, pos.y + 100f))
polylines.add(FloatPoint(pos.x - 50f, pos.y + 150f))
return KNMapPolyline(polylines,
lineColor = Color.YELLOW,
lineWidth = 3f,
lineDashType = KNLineDashType.KNLineDashType_Dotted,
priority = 1).apply {
val addPointInfo = arrayListOf()
addPointInfo.add(FloatPoint(pos.x - 50f, pos.y - 50f))
addPointInfo.add(FloatPoint(pos.x + 50f, pos.y - 50f))
addPointInfo.add(FloatPoint(pos.x + 50f, pos.y + 50f))
addPointInfo.add(FloatPoint(pos.x - 50f, pos.y + 50f))
addPoints(addPointInfo)
}
}fun addPoints( points: List<FloatPoint> )Parameters
| Name | Description |
|---|---|
points | List of line vertices |