ReviewOS

craft-native/craft

Map overlays can only be child nodes, so hundreds of shapes means hundreds of nodes

#377
Closed glennmichael123 opened this 8 days ago · {{ comments.length }} {{ comments.length === 1 ? 'comment' : 'comments' }}
8 days ago

What is missing

A way to give a <Map> its overlays as data. Today they can only be child nodes — MapProps has no polylines, markers or annotations array — so a map of N shapes is N nodes in the document.

Why it matters

Wildloop's territory map asks the API for up to 500 zones and draws one boundary each:

<Map testID="territory-map" :fitToBounds="true" mapType="standard">
  <MapPolyline :for="shape in shapes()" :key="shape.id"
    :geometry="shape.geometry" :strokeColor="shape.color" :strokeWidth="3" />
</Map>

Each of those is a createNode plus an insertChild plus an updateNode carrying a flat coordinate array, through the mutation protocol, for something the host immediately flattens back into [CLLocationCoordinate2D]. The node tree gains hundreds of children that exist only to be read once as geometry.

It also makes the overlay set harder to reason about from the outside. Tracing why a map was not framing its content, I had to establish from the operation stream whether looped children were reaching configure at all:

RENDER map children: ["MapPolyline"]        ← the :for template
INSERTS INTO MAP: n54, n55                   ← the real ones, later
MAP NODE PATCHES: []                         ← the Map itself never patched

That turned out to be fine — insertChild adds the parent to affectedNodeIds and the map is reconciled — but a data prop would make it a non-question.

What would help

Accept arrays alongside the children, the way the underlying SDKs do:

export interface MapProps extends BaseProps {
  polylines?: Array<{ id: string, geometry: number[], strokeColor?: string, strokeWidth?: number }>
  markers?: Array<{ id: string, geometry: number[], title?: string, bearing?: number }>
}

Children stay for the handful-of-shapes case; the array is for the hundreds case. configure already builds nextPolylines / nextMarkers dictionaries keyed by id, so the shape of the data matches what the host wants.

Versions

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

8 days ago

Implemented on main in f5c2bda3 (TypeScript/data contract) and 8e84945c (Android reconciliation), with iOS already consuming keyed overlay dictionaries. The open issue is stale relative to the current map host contract and needs closure.

8 days ago

Resolved on main by f5c2bda and 8e84945. Map overlays now accept data-driven arrays and reconcile in place on both maintained hosts, with source-contract coverage. On main, unreleased.

Sign in to comment on this issue.