ReviewOS

craft-native/craft

No map polygon: an area can only be drawn as its own outline, never filled

#376
Closed glennmichael123 opened this 8 days ago ·
8 days ago

What is missing

A map overlay that encloses an area. Craft ships two:

export interface MapPolylineProps extends BaseProps {
  geometry: number[]
  strokeColor?: string
  strokeWidth?: number
}
export interface MapMarkerProps extends BaseProps {
  geometry: number[]
  id: string
  title?: string
  bearing?: number
}

A line and a pin. There is no polygon, and a polyline has no fill, so an area can only be drawn as its own outline.

Why it matters

Wildloop's central feature is territory: you run a closed loop and the ground inside it becomes yours. The map is supposed to answer "whose is this?" at a glance, and the screen's own copy says "Green is yours. Run a closed loop to claim new ground."

Nothing can be green. Every zone is a hollow ring — the line is coloured by owner and the interior is whatever basemap is underneath, so two adjacent territories owned by different people read as two outlines rather than two areas. On a zoomed-out map, where a zone is a few hundred points across, an unfilled ring is close to invisible.

The workaround is to close the ring ourselves and accept the outline:

// resources/functions/territories.ts — the ring is closed by hand because a
// polyline does not close itself, and there is nothing to fill it with.
export function territoryGeometry(ring: number[][]): number[]

What would help

MapPolygon with the props MapKit's MKPolygon and Android's Polygon already share:

export interface MapPolygonProps extends BaseProps {
  geometry: number[]          // flat lat,lng pairs, as MapPolyline takes
  holes?: number[][]          // optional interior rings
  fillColor?: string
  strokeColor?: string
  strokeWidth?: number
}

Both platforms have the primitive natively (MKPolygon / MKPolygonRenderer, com.google.android.gms.maps.model.Polygon), so this is a binding rather than new drawing code.

Secondary, same area

Polygon geometry maths is also absent, so apps reimplement it in JavaScript. We carry our own area, centroid, ring-closing and point-in-box helpers (resources/functions/territories.ts, map-area.ts) while MKPolygon and Core Location already compute them. Not a blocker — just where the duplication comes from.

Versions

craft-native 0.0.237, @stacksjs/stx 0.2.563, iOS 26.5 simulator, Xcode 26.6.

8 days ago

Implemented on main: 9f172be0 adds host-neutral MapPolygon props and renderer support; b4455e79 publishes the TypeScript contract; 6322912c keeps iOS fit-to-bounds invalidation correct after polygon changes. The open issue is now stale relative to main and needs closure.

8 days ago

Resolved on main by 9f172be, b4455e7, 6322912. MapPolygon is in the shared type contract and both hosts, including fit invalidation when polygon data changes. On main, unreleased.

Sign in to comment on this issue.