new TilesOverlayCatalog()
BeNomad BeMap JavaScript API — TilesOverlayCatalog (v2.0)
Per-map catalogue of user overlays (markers, polylines, polygons, circles,
popups, cluster layers, raster layers, heatmaps, draw layer). Native
MapLibre `setStyle()` wipes user-added sources/layers; this catalogue
captures **factories** that recreate each overlay so the library can
replay them after a style swap — including the 401 → relogin → setStyle
path that would otherwise destroy customer overlays mid-session.
Public API:
- `register(type, id, factory)` — `factory(map)` runs after `setStyle`
- `unregister(type, id)` — drop a factory from the catalogue
- `replayOnto(map)` — iterate insertion-order, invoke each
- `clear()` — empty the catalogue
- `size()` — number of registered overlays
- Since:
- 2.0.0
- Source:
Methods
clear()
entries()
Iterate over (type, id) entries in registration order. Useful for tests.
register(type, id, factory)
Register an overlay factory. Calling with the same (type, id) replaces
the previous registration (move-to-end).
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | `'marker'` | `'polyline'` | etc. |
id |
String | Unique within its type. |
factory |
function | `function(map)` — receives the map instance, no return required. |
replayOnto()
Run every registered factory against the given map, in insertion order.
Factories that throw are caught and surfaced via the map's error channel
(when available); they do not abort the replay loop.
size() → {Number}
Returns:
- Type
- Number