Docs / Basics / Polygon

Polygon

An area defined by an outer ring plus any number of holes. Add a fill and a stroke, place it in the map view, and you have area highlighting or a mask. Holes are where map SDKs get quirky — MapConductor makes the result identical on every provider.

POINTS
GeoPoint[]
HOLES
GeoPoint[][]
FILL / STROKE
color · width
GEODESIC
true / false
Platform

01 · Polygon state

PolygonState represents one area: outer ring, holes, fill, stroke and a tap handler. Assign to a property and the shape updates in place, so vertex-dragging editors are just coordinate swaps.

PolygonPageViewModel.kt · Jetpack Compose
val polygonState =
    PolygonState(
        points = outerRing,
        holes = listOf(holeA, holeB),
        strokeColor = Color.Red,
        strokeWidth = 3.dp,
        fillColor = Color(0x4D0064E6),
        onClick = { event -> viewModel.onPolygonClick(event) },
    )

Polygon(polygonState)

// 頂点や穴は書き換えるだけで更新される
polygonState.holes = nextHoles
Property
Description
points
The outer ring; closing is handled internally, so no need to repeat the first point.
holes
An array of hole rings. Several are fine, and they may overlap.
fillColor
Fill colour, with transparency from its alpha.
strokeColor / strokeWidth
Stroke colour and width for the outline; width is in logical units, so it looks the same at any density.
geodesic
Whether edges follow great circles — visible on wide areas.
zIndex · extra
Stacking order and an arbitrary payload.
onClick
Tap handler; receives the polygon state and the tapped coordinate.

02 · Holes and merging overlaps

Holes cut regions out of the outer ring. In mask-style designs you often place several holes for the places you want to reveal — and those holes naturally end up overlapping.

Given overlapping holes, most map SDKs draw an outline where they overlap, exposing the seam between them. MapConductor unions the holes before drawing, so an overlap becomes a single hole and no extra lines appear.

Figure · passing two overlapping triangular holes
RAW SDK
The overlap is passed through and outlines appear across it — you can see that there are two holes.
MAPCONDUCTOR
Holes are unioned first: the overlap becomes one hole, and only its outer shape is stroked.
The application code and the hole coordinates are identical in both cases. The union happens as the state is built, so it keeps up while vertices are dragged in and out of overlap.
Passing overlapping holes as-is
// 重なり合う穴をそのまま渡してよい。内部で1つの穴に結合される
PolygonState(
    points = outerRing,
    holes =
        listOf(
            triangleA, // ← 互いに重なっている
            triangleB,
        ),
    fillColor = Color(0xCC787880),
)

03 · The same result on every provider

Beyond hole overlaps, filled areas expose plenty of per-engine differences. MapConductor absorbs them so one PolygonState gives one picture.

HOLE UNION

Overlapping holes are merged

Overlaps are unioned into a single region as the state is built — no outline across the overlap and no doubled fill.

GEODESIC

The same shape without curve support

Engines that cannot draw great circles receive a densified ring instead, so wide areas match everywhere.

ANTIMERIDIAN

Areas crossing the date line

Rings crossing 180° are split at the boundary, so engines that would fill the long way round still fill the right side.

HIT TEST

Shared tap detection

Tap detection is shared logic and holes do not respond, whether or not the underlying engine accounts for them.

04 · Tapping

onClick receives the polygon state and the tapped coordinate — read the fill or the extra payload to show details.

event.state
The tapped polygon state; read its fill colour or extra payload.
event.clicked
The tapped geographic coordinate.
Holes do not respond
Tapping inside a hole fires nothing for that polygon; only the visible fill counts.
PolygonClickPageViewModel.kt
fun onPolygonClicked(event: PolygonEvent) {
    markerState = MarkerState(
        position = event.clicked,
        icon = DefaultMarkerIcon(fillColor = event.state.fillColor),
    )
}

Where polygons overlap, the higher zIndex wins. Polygons outside the visible region are skipped, so many wide areas stay responsive.

Related pages