Drawing a circle
Create a KNMapCircle (KO) object and register it with KNMapView 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.
-(void)addCircle01 {
IntPoint mapPos = [[KNSDK sharedInstance] convertWGS84ToKATECWithLongitude:127.11019081347423 latitude:37.3941851228957];
KNMapCircle *circle = [KNMapCircle circleWithCenter:FloatPointMake(mapPos.x, mapPos.y) radius:100.0f];
circle.strokeColor = [UIColor redColor];
circle.fillColor = [UIColor blueColor];
circle.strokeWidth = STROKE_WIDTH;
circle.strokeDashType = KNLineDashType_Solid;
circle.isVisible = YES;
circle.priority = PRIORITY;
circle.tag = CIRCLE_01;
[self->mapView addCircle:circle];
}Removing a circle
Use the removeCircle function to remove a circle you have added.
-(void)removeCircle01 {
NSArray* circles = [self getCirclesWithTag:CIRCLE_01];
for (KNMapCircle *circle in circles) {
[self->mapView removeCircle:circle];
}
}Drawing a line
Create a KNMapPolyline (KO) object and register it with KNMapView to add a line to the map.
Set the line color, the line type, and other properties in the KNMapPolyline (KO) class.
-(void)addLine01 {
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase2.csv" ofType:nil]];
KNMapPolyline *mapPolyline = [KNMapPolyline polylineWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
mapPolyline.lineColor = [UIColor redColor];
mapPolyline.lineDashType = KNLineDashType_Solid;
mapPolyline.lineWidth = STROKE_WIDTH;
mapPolyline.isVisible = YES;
mapPolyline.priority = PRIORITY;
mapPolyline.tag = POLYLINE_01;
[self->mapView addPolyline:mapPolyline];
}Removing a line
Use the removePolyline function to remove a line you have added.
-(void)removeLine01 {
NSArray* lines = [self getPolylinesWithTag:POLYLINE_01];
for (KNMapPolyline *line in lines) {
[self->mapView removePolyline:line];
}
}Drawing a polygon
Create a KNMapPolygon (KO) object and register it with KNMapView 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.
-(void)addPolygon01 {
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase5.csv" ofType:nil]];
KNMapPolygon* polygon = [[KNMapPolygon alloc] polygonWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
polygon.fillColor = [UIColor redColor];
polygon.strokeColor = [UIColor greenColor];
polygon.strokeWidth = STROKE_WIDTH;
polygon.strokeDashType = KNLineDashType_Solid;
polygon.isVisible = YES;
polygon.priority = PRIORITY;
polygon.tag = POLYGON_01;
if(objectLoader.holeCnt > 0)
{
[polygon addHoleWithPoints:objectLoader.holePosition countPoints:objectLoader.holeCnt];
}
[self->mapView addPolygon:polygon];Removing a polygon
Use the removePolygon function to remove a polygon you have added.
-(void)removePolygon01 {
NSArray* polygons = [self getPolygonsWithTag:POLYGON_01];
for (KNMapPolygon *polygon in polygons) {
[self->mapView removePolygon:polygon];
}
}