KNMapPolygon
INFO
This English reference is based on Directions SDK 1.12.12. For the latest version, see the Korean reference.
Creates a Polygon to display on the map. You can configure its fill color, outline, and line style. A Polygon connects KATEC coordinate vertices, which you must provide in clockwise order. To add it to the map, create a KNMapPolygon object and register it with KNMapView.
Properties
| Name | Description | Type |
|---|---|---|
fillColor | Fill color of the polygon | @property (nonatomic, assign, nonnull) UIColor* fillColor |
strokeColor | Outline color of the polygon. If you create a hole in the polygon with addHoleWithPoints, the same setting applies to the outline of the hole. | @property (nonatomic, assign, nonnull) UIColor* strokeColor |
strokeWidth | Outline thickness of the polygon. (default: 2, outline thickness setting range: 1 to 5) | @property (nonatomic, assign) float strokeWidth |
strokeDashType | Outline type of the polygon. You can set a solid, dotted, dashed, dash-dotted, or dash-double-dotted line. (default: KNLineDashType_Solid) | @property (nonatomic, assign) KNLineDashType strokeDashType |
priority | Display priority of the polygon. A higher number is displayed on top. (default: 0, priority setting range: 0 to 65535) | @property (nonatomic, readwrite, assign) NSInteger priority |
isVisible | Whether the polygon is visible. (default: YES) | @property (nonatomic, assign) BOOL isVisible |
tag | Tag assigned to the Polygon (tag). Use this integer value to categorize or identify the Polygon. (optional) | @property (nonatomic, assign) NSInteger tag |
TIP
Marker priority is always higher than that of other Overlay objects, such as Circle, Polygon, and Polyline. Therefore, a Marker appears on the top layer when objects overlap.
Example code — KNMapPolygon Example code for using the property
// Set the fill color of the polygon
polygon.fillColor = [UIColor blueColor];
UIColor* fillColor = polygon.fillColor;
// Set the stroke color of the polygon
polygon.strokeColor = [UIColor blueColor];
UIColor* strokeColor = polygon.strokeColor;
// Set the stroke width of the polygon
polygon.strokeWidth = newValue;
float strokeWidth = polygon.strokeWidth;
// Set the stroke type of the polygon
polygon.strokeDashType = KNLineDashType_Solid;
KNLineDashType dashType = polygon.strokeDashType;
// Set the display priority of the polygon
polygon.priority = newValue;
NSInteger priority = polygon.priority;
// Set whether to show the polygon
polygon.isVisible = newValue;
BOOL visible = polygon.isVisible;
// Set the tag for the polygon
polygon.tag = newValue;
NSInteger tag = polygon.tag;Constructor
polygonWithPoints:countPoints
Creates a KNMapPolygon object from KATEC coordinate vertices. Provide the vertices in clockwise order.
- (KNMapPolygon* _Nonnull)polygonWithPoints:(FloatPoint* _Nonnull)aPoints countPoints: (int)aCountPoints;Example code — - polygonWithPoints:countPoints:
float length = 20.0;
FloatPoint pos = mapView.coordinateCenter;
FloatPoint p01 = FloatPointMake(pos.x, pos.y + length*3.0);
FloatPoint p02 = FloatPointMake(pos.x - length, pos.y + length);
FloatPoint p03 = FloatPointMake(pos.x - length*3.0, pos.y + length);
FloatPoint p04 = FloatPointMake(pos.x - length*1.5, pos.y);
FloatPoint p05 = FloatPointMake(pos.x - length*3.0, pos.y - length*3.0);
FloatPoint p06 = FloatPointMake(pos.x, pos.y - length);
FloatPoint p07 = FloatPointMake(pos.x + length*3.0, pos.y - length*3.0);
FloatPoint p08 = FloatPointMake(pos.x + length*1.5, pos.y);
FloatPoint p09 = FloatPointMake(pos.x + length*3.0, pos.y + length);
FloatPoint p10 = FloatPointMake(pos.x + length, pos.y + length);
FloatPoint points[] = { p01, p02, p03, p04, p05, p06, p07, p08, p09, p10 };
KNMapPolygon* polygon = [[KNMapPolygon alloc] polygonWithPoints:points countPoints:10];
polygon.fillColor = [UIColor blueColor];
polygon.strokeColor = [UIColor yellowColor];
polygon.strokeWidth = STROKE_WIDTH;
polygon.strokeDashType = KNLineDashType_Solid;
polygon.isVisible = YES;
polygon.priority = PRIORITY;
polygon.tag = POLYGON_03;
[self->mapView addPolygon:polygon];Methods
addHoleWithPoints:countPoints
Adds a hole to the Polygon. Provide the KATEC coordinate vertices as a list in clockwise order.
Example code — - addHoleWithPoints:countPoints:
[polygon addHoleWithPoints:points countPoints:pointsCount];- (void) addHoleWithPoints: (FloatPoint* _Nonnull) aPoints
countPoints: (int) aCountPoints