Conversation
Introduces a new `useGeoJSON` composable that abstracts MapLibre source and layer management into a simple, instance-scoped API. Motivated by a mobile rendering bug in the recordings example caused by raw MapLibre layer setup; the new API fixes that and provides a clean foundation for all future GeoJSON rendering. ## useGeoJSON API (src/composables/useGeoJSON.js) - `setFeature(feature)` — add or update a GeoJSON Feature by id - `removeFeature(id)` — remove a feature from the map - `clearFeatures()` — remove all features - `setDefaults(defaults)` — set default styles per geometry type Style is driven by `navigator.*` properties on the feature: - `navigator.color` — fill/stroke colour (auto-assigned bright primary if absent) - `navigator.opacity`, `navigator.width`, `navigator.radius`, `navigator.fillOpacity` Supports Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon. Uses round line caps/joins for smooth mobile rendering. Features queued before map:ready are applied automatically on load. Sources and layers are cleaned up on destroy with no extra teardown code required. Exported from `@ogis/navigator` public API. Works in both plugin install() (pass instanceId explicitly) and Vue component setup() (resolved via inject). ## Tests (tests/unit/useGeoJSON.test.js) Full unit test coverage: 88 tests covering setFeature, removeFeature, clearFeatures, setDefaults, auto-colour assignment, invalid input, geometry type detection, and map lifecycle (pre-ready queuing, destroy cleanup). ## Recordings example updated (docs/extend/feature/recordings.js) Replaced raw addSource/addLayer/setData calls with useGeoJSON. The active track is now rendered via setFeature() / removeFeature(), with colour toggled via navigator.color property on pause/resume. Crash recovery re-queues the restored track before mount via the same setFeature() call. ## Docs - Add docs/core/5.geojson.md — full API reference with examples - Renumber core docs: locale 5→6, theme 6→7, testing 7→8 - Update docs/extend/5.features.md to reflect useGeoJSON patterns; remove 'Build a feature inside Navigator source' from summary table - Add GitHub-style [!NOTE]/[!TIP] alerts to extend docs for cross-references to core, replacing plain-text pointers that blurred the audience boundary - Update AGENTS.md, README, and copilot-instructions with current state ## Other - bump: 1.0.24 → 1.0.25 - fix: npm test now runs vitest only; E2E separated to test:e2e - chore: remove FEEDBACK.md; add TASKS.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a new
useGeoJSONcomposable that abstracts MapLibre source and layer management into a simple, instance-scoped API. Motivated by a mobile rendering bug in the recordings example caused by raw MapLibre layer setup; the new API fixes that and provides a clean foundation for all future GeoJSON rendering.useGeoJSON API (src/composables/useGeoJSON.js)
setFeature(feature)— add or update a GeoJSON Feature by idremoveFeature(id)— remove a feature from the mapclearFeatures()— remove all featuressetDefaults(defaults)— set default styles per geometry typeStyle is driven by
navigator.*properties on the feature:navigator.color— fill/stroke colour (auto-assigned bright primary if absent)navigator.opacity,navigator.width,navigator.radius,navigator.fillOpacitySupports Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon. Uses round line caps/joins for smooth mobile rendering. Features queued before map:ready are applied automatically on load. Sources and layers are cleaned up on destroy with no extra teardown code required.
Exported from
@ogis/navigatorpublic API. Works in both plugin install() (pass instanceId explicitly) and Vue component setup() (resolved via inject).Tests (tests/unit/useGeoJSON.test.js)
Full unit test coverage: 88 tests covering setFeature, removeFeature, clearFeatures, setDefaults, auto-colour assignment, invalid input, geometry type detection, and map lifecycle (pre-ready queuing, destroy cleanup).
Recordings example updated (docs/extend/feature/recordings.js)
Replaced raw addSource/addLayer/setData calls with useGeoJSON. The active track is now rendered via setFeature() / removeFeature(), with colour toggled via navigator.color property on pause/resume. Crash recovery re-queues the restored track before mount via the same setFeature() call.
Docs
Other