Polygon

class Polygon(points: List<LatLng>, strokeColor: Color = Color.Black, strokeWidth: Float = 10.0f, strokePattern: PathEffect? = null, pattern: List<PatternItem>? = null, strokeCap: StrokeCap = StrokeCap.Butt, strokeJoin: StrokeJoin = StrokeJoin.Round, fillColor: Color = Color(red = 128, green = 128, blue = 128, alpha = 128), holes: List<List<LatLng>> = emptyList(), geodesic: Boolean = false, visible: Boolean = true, clickable: Boolean = false, zIndex: Float = 0.0f, tag: Any? = null)(source)

A polygon on the map: a closed shape with optional holes.

The polygon is a live handle, as returned by OpenMapView.addPolygon: setting a property, e.g. polygon.strokeWidth = 16f, redraws the map right away, and remove takes it off the map. Java code uses the getters and setters, e.g. polygon.setStrokeColor(0xFFFF0000).

Parameters

points

the geographic coordinates of the outline, at least 3; the last point connects to the first

strokeColor

the outline color

strokeWidth

the outline width in pixels

strokePattern

the stroke pattern, e.g. dashed; null for a solid line

pattern

the stroke pattern as dots, dashes and gaps, used instead of strokePattern if not null

strokeCap

the shape of line ends

strokeJoin

the shape of the corners

fillColor

the color of the interior

holes

holes cut out of the interior, each with at least 3 points

geodesic

whether segments are drawn as great-circle paths instead of straight lines on the Mercator map

visible

whether the polygon is visible

clickable

whether a tap on the polygon is reported to its click listener

zIndex

draw order: polygons with a higher zIndex are drawn on top

tag

optional user data

Constructors

Link copied to clipboard
constructor(points: List<LatLng>, strokeColor: Color = Color.Black, strokeWidth: Float = 10.0f, strokePattern: PathEffect? = null, pattern: List<PatternItem>? = null, strokeCap: StrokeCap = StrokeCap.Butt, strokeJoin: StrokeJoin = StrokeJoin.Round, fillColor: Color = Color(red = 128, green = 128, blue = 128, alpha = 128), holes: List<List<LatLng>> = emptyList(), geodesic: Boolean = false, visible: Boolean = true, clickable: Boolean = false, zIndex: Float = 0.0f, tag: Any? = null)

Properties

Link copied to clipboard

Whether a tap on the polygon is reported to its click listener

Link copied to clipboard

The color of the interior

Link copied to clipboard

fillColor as an ARGB color int, e.g. for Java code.

Link copied to clipboard

Whether segments are drawn as great-circle paths instead of straight lines on the Mercator map

Link copied to clipboard

Holes cut out of the interior, each with at least 3 points

Link copied to clipboard
val id: String

The unique id of this polygon, e.g. "pg0", which stays the same for its lifetime. copy returns a polygon with a new id.

Link copied to clipboard

The stroke pattern as dots, dashes and gaps, used instead of strokePattern if not null

Link copied to clipboard

The geographic coordinates of the outline, at least 3; the last point connects to the first

Link copied to clipboard

The shape of line ends

Link copied to clipboard

The outline color

Link copied to clipboard

strokeColor as an ARGB color int, e.g. for Java code.

Link copied to clipboard

The shape of the corners

Link copied to clipboard

The stroke pattern, e.g. dashed; null for a solid line

Link copied to clipboard

The outline width in pixels

Link copied to clipboard
var tag: Any?

Optional user data

Link copied to clipboard

Whether the polygon is visible

Link copied to clipboard

Draw order: polygons with a higher zIndex are drawn on top

Functions

Link copied to clipboard
fun copy(points: List<LatLng> = this.points, strokeColor: Color = this.strokeColor, strokeWidth: Float = this.strokeWidth, strokePattern: PathEffect? = this.strokePattern, pattern: List<PatternItem>? = this.pattern, strokeCap: StrokeCap = this.strokeCap, strokeJoin: StrokeJoin = this.strokeJoin, fillColor: Color = this.fillColor, holes: List<List<LatLng>> = this.holes, geodesic: Boolean = this.geodesic, visible: Boolean = this.visible, clickable: Boolean = this.clickable, zIndex: Float = this.zIndex, tag: Any? = this.tag): Polygon

Returns a new polygon with the given properties changed, not added to any map.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

The fill color as an ARGB color int, like getFillColor() of the Maps SDK.

Link copied to clipboard

The shape of line ends as a Cap, e.g. for Java code.

Link copied to clipboard

The stroke color as an ARGB color int, like getStrokeColor() of the Maps SDK.

Link copied to clipboard

The shape of the corners as a JointType constant, like getStrokeJointType() of the Maps SDK.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun remove()

Removes the polygon from the map that shows it.

Link copied to clipboard
fun setFillColor(color: Int)

Sets the fill color from an ARGB color int, like setFillColor(int) of the Maps SDK.

Link copied to clipboard
fun setStrokeCap(cap: Cap)

Sets the shape of line ends, e.g. setStrokeCap(new RoundCap()) from Java.

Link copied to clipboard
fun setStrokeColor(color: Int)

Sets the stroke color from an ARGB color int, like setStrokeColor(int) of the Maps SDK.

Link copied to clipboard
fun setStrokeJointType(jointType: Int)

Sets the shape of the corners from a JointType constant, like setStrokeJointType(int) of the Maps SDK.

Link copied to clipboard

Sets strokePattern from an android.graphics.PathEffect, e.g. a DashPathEffect from Java.

Sets pattern from dots, dashes and gaps, like setStrokePattern(List) of the Maps SDK.