Appearance
Detected objects visibility toggle design
Background
The SDK already supports rendering detected objects through drawDetectedObjects(), but it does not provide a runtime switch to hide or show them. This design adds runtime.showDetectedObjects so callers can toggle visibility without changing detected object data.
Goal and scope
This design defines how to add a runtime visibility toggle for detected objects.
- Add
runtime.showDetectedObjectswith a default value oftrue. - Let consumers hide and show all detected objects at runtime.
- Keep existing detected object data synchronization behavior unchanged.
Out of scope:
- Per-object visibility flags.
- New public methods for detected object visibility.
- Data deletion when visibility is turned off.
Approaches considered
This section summarizes three options and their trade-offs.
Recommended: manager-level runtime subscription
- Add
showDetectedObjectsto runtime types and defaults. - Subscribe in
DetectedObjectManagerand toggleLAYER_DETECTED_OBJECT.visible. - Pros: aligns with current manager pattern, minimal code impact, no unnecessary object recreation.
- Cons: requires one additional subscription and cleanup path.
- Add
MapApplication-level runtime dispatch
- Detect runtime changes in
MapApplication.updateRuntime()and call a manager method. - Pros: centralized runtime handling.
- Cons: increases coupling and makes
updateRuntime()heavier over time.
- Detect runtime changes in
Per-object subscription in DetectedObject component
- Each detected object subscribes to runtime visibility updates.
- Pros: local component autonomy.
- Cons: scales poorly with many objects and adds avoidable subscription overhead.
Selected design
The selected design uses option 1: manager-level runtime subscription.
Runtime schema and defaults
Add a new runtime field:
RuntimeConfig.showDetectedObjects: booleanDEFAULT_RUNTIME_CONFIG.showDetectedObjects = true
This keeps backward compatibility because current behavior is to render detected objects by default.
Rendering control point
DetectedObjectManager becomes the single control point for this visibility state.
- On initialization, subscribe to
runtime.showDetectedObjects. - In the callback, read
LAYER_DETECTED_OBJECTfromAppContainerand set the layer visibility. - Keep
drawDetectedObjects()behavior unchanged for create/update/remove data flow.
This means visibility control is independent from data synchronization.
Lifecycle and cleanup
DetectedObjectManager.destroy() must also unsubscribe from the new runtime listener to avoid stale callbacks.
Impacted files
This change affects the following files.
src/core/@types/index.d.ts- Add
showDetectedObjectstoRuntimeConfig.
- Add
src/core/constant/config.ts- Add
showDetectedObjects: truetoDEFAULT_RUNTIME_CONFIG.
- Add
src/core/managers/DetectedObjectManager.ts- Add runtime subscription and layer visibility toggle.
- Add unsubscribe cleanup in
destroy().
src/app/debugTools/index.ts(optional)- Add a debug toggle action for
showDetectedObjects.
- Add a debug toggle action for
Edge cases
The implementation handles these expected cases.
- If the detected object layer is not available yet, the visibility callback exits safely.
- If visibility is off and new detected object data arrives, manager data state still updates, and objects become visible immediately after toggling on.
Verification strategy
Per user request, this task does not include a dedicated test execution step.
Next steps
After this design is accepted, create an implementation plan and then apply the code changes in the impacted files.