Skip to content

Add onAddStart/onAddProgress/onAddEnd to Markers, Circles, Polylines, Polygons - #42

Merged
wf9a5m75 merged 1 commit into
developfrom
feat/add-progress
Nov 13, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
feat/add-progress

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

These callbacks show that a long list is being put on the map. They mean the same as in js-sdk-react (MapConductor/js-sdk-react#17) and android-sdk-compose (MapConductor/android-sdk-compose#16):

  • onAddStart(total) comes when the list brings states that are not on the map yet.
  • onAddProgress(added, total) comes at most every 100 ms, and once more at added == total.
  • onAddEnd(total) comes when all of them are on the map. That is the moment each state's onAdded fires; for tiled states, it is when their tiles are handed to the map.
  • A state removed before it arrives no longer counts. A new list that adds states starts over, and the earlier list gets no onAddEnd. A list that only updates or removes states calls nothing.
  • Callbacks run on the main actor and never during a view update.

How it works on iOS. The collections are values rebuilt on every content pass, so they keep no count themselves. Instead:

  • Circles(...) and the others put an AddProgressRequest into MapViewContent, but only when a callback is set.
  • MapViewBase, which every provider except the template wraps its map in, keeps the counts in a @StateObject for the life of the map view. No provider needs changing.
  • Each collection is identified by where it is written: #fileID, #line and #column defaults, plus its order when the same line repeats in a loop. It starts from nothing when it leaves the content and comes back, and when the map is recreated.
  • An unchanged list is recognised by its array storage, so a camera frame costs nothing; the list is walked only when it changes.
  • OverlayAddedListeners (@_spi(MapConductorDriver)) passes each batch that OverlayAddedTracker.notify reports to the counts.

Also: StrategyMarkerController now calls onAdded, including for markers held until the first camera, as the web and Android versions already did.

Tests: AddProgressTests (11 cases) and StrategyMarkerClearOrderTests.testOnAddedForDirectAndHeldMarkers. The whole suite passes (557) on the iPhone 17 Pro simulator.

Checked in the sample: antenna-horizons (723,800 circles, MapLibre, simulator, Release) logged start 723800, then progress 723800/723800 and end 5.7 s later.

… Polygons

A list of thousands shows nothing until it is drawn; these say the work is going on.
They count the states a list brings by the same moment as each state's onAdded,
report progress at most every 100 ms, and start over when a new list adds states,
the same as js-sdk-react and android-sdk-compose.

The collections are values rebuilt on every content pass, so the counts live in
MapViewBase (a StateObject per map view), keyed by where each collection is
written; an unchanged list is recognised by its storage and costs nothing.
OverlayAddedListeners lets them hear the states OverlayAddedTracker reports.

StrategyMarkerController now calls onAdded too, as on the web and Android.
@wf9a5m75
wf9a5m75 merged commit 6041010 into develop Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant