Drawing a circle
Create a KNMapCircle (KO) object and register it with KNMapView (KO) to add a circle to the map.
Set the outline and fill colors of the circle, the line type, and other properties in the KNMapCircle (KO) class.
private fun circleAdd() {
val polygonData = mutableListOf<KNTestCaseManager.PolygonData>()
KNTestCaseManager.testCaseData["testcase11.csv"]?.apply {
if (typeCase.trim() != KNTestCaseManager.CIRCLE) return@apply
polygonData.add(this)
}
if (polygonData.isEmpty()) {
polygonData.add(KNTestCaseManager.PolygonData(KNTestCaseManager.CIRCLE,
listOf(WGS84ToKATEC(127.11019081347423, 37.3941851228957)),
mutableListOf(),
100f))
}
polygonData.forEach {
this@FragmentMapSample00.mapView.addCircle(KNMapCircle(it.point.first(),it.radius,
fillColor = Color.TRANSPARENT).apply {
testType2.add(this)
})
}
}Removing a circle
Use the removeCircle (KO) function to remove a circle you have added.
private fun circleRemove() {
testType2.forEach {
this@FragmentMapSample00.mapView.removeCircle(it)
}
testType2.clear()
}Drawing a line
Create a KNMapPolyline (KO) object and register it with KNMapView (KO) to add a line to the map.
Set the line color, the line type, and other properties in the KNMapPolyline (KO) class.
private fun lineAdd() {
val polygonData = mutableListOf<KNTestCaseManager.PolygonData>()
KNTestCaseManager.testCaseData["testcase2.csv"]?.apply {
if (this.typeCase.trim() != KNTestCaseManager.POLYLINE) return
polygonData.add(this)
}
polygonData.forEach {
this@FragmentMapSample00.mapView.addPolyline(KNMapPolyline(it.point, lineWidth = 5f, lineColor = Color.MAGENTA).apply {
testType1.add(this)
})
}
}Removing a line
Use the removePolyline (KO) function to remove a line you have added.
private fun lineRemove() {
testType1.forEach {
this@FragmentMapSample00.mapView.removePolyline(it)
}
testType1.clear()
}Drawing a polygon
Create a KNMapPolygon (KO) object and register it with KNMapView (KO) to add a polygon to the map.
Set the outline and fill colors of the polygon, the line type, and other properties in the KNMapPolygon (KO) class.
private fun polygonAdd() {
val polygonData = mutableListOf<KNTestCaseManager.PolygonData>()
KNTestCaseManager.testCaseData["testcase6.csv"]?.apply {
if (this.typeCase.trim() != KNTestCaseManager.POLYGON) return
polygonData.add(this)
}
polygonData.forEach {
this@FragmentMapSample00.mapView.addPolygon(KNMapPolygon(it.point).apply {
testType3.add(this)
})
}
}Drawing a polygon with a hole
Use the addHole (KO) function to create a hole in a polygon.
Set the outline and fill colors of the polygon hole, the line type, and other properties in the KNMapPolygon (KO) class.
private fun polygonWithHoleAdd() {
val polygonData = mutableListOf<KNTestCaseManager.PolygonData>()
KNTestCaseManager.testCaseData["testcase5.csv"]?.apply {
if (this.typeCase.trim() != KNTestCaseManager.POLYGON) return
polygonData.add(this)
}
polygonData.forEach {
this@FragmentMapSample00.mapView.addPolygon(KNMapPolygon(it.point).apply {
addHole(it.hole)
testType4.add(this)
})
}
}Removing a polygon
Use the removePolygon (KO) function to remove a polygon you have added.
private fun polygonWithHoleRemove() {
testType4.forEach {
this@FragmentMapSample00.mapView.removePolygon(it)
}
testType4.clear()
}