Skip to content

docs: document leaflet_options.js config and remove dead baselayer#488

Merged
DennisOSRM merged 3 commits into
gh-pagesfrom
docs/leaflet-options-179
Jul 4, 2026
Merged

docs: document leaflet_options.js config and remove dead baselayer#488
DennisOSRM merged 3 commits into
gh-pagesfrom
docs/leaflet-options-179

Conversation

@DennisOSRM

@DennisOSRM DennisOSRM commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #179 — the configuration options in src/leaflet_options.js have been undocumented for years, causing confusion about layer vs baselayer, how to set the default tile layer, what overlays do, and how services work.

Changes

src/leaflet_options.js

  • Added comprehensive JSDoc for the module export and all internal functions — covering every property, its purpose, structure, and how to customize it
  • Removed the dead baselayer property — it duplicated layer and was never referenced in production code (only in tests)
  • Honored explicit mode.profile in parseModes() — falls back to positional assignment (driving → bike → foot) when not specified
  • Module-level docblock now includes a table of all runtime environment variables

test/leaflet_options.test.js

  • Migrated all baselayer.* references to layer[0]['DisplayName'] — same assertions, same coverage

README.md

  • Added a new "Customizing Tile Layers and Overlays" section documenting all base layers, overlays, and how to customize them with code examples
  • Updated the outdated "Changing Backends" section to reference OSRM_MODES

Verification

  • ✅ All 224 tests pass
  • ✅ Build and dev server start without errors

AI assistance: Claude helped draft the JSDoc, README content, and test migration. All changes were reviewed and verified by a human.

)

Add comprehensive JSDoc for the leafletOptions export and its internal
functions. Remove the unused baselayer property (duplicated layer, never
referenced in production code). Migrate test references to layer[0].

Add README section on customizing tile layers and overlays for self-hosters.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves OSRM Frontend configurability documentation by adding detailed inline docs for src/leaflet_options.js, removing the unused baselayer export in favor of the canonical layer structure, and updating developer-facing docs/tests to match (addressing #179).

Changes:

  • Added comprehensive JSDoc for src/leaflet_options.js config surface and helper functions, including runtime env var documentation.
  • Removed the dead baselayer export and migrated tests to reference layer[0][<Display Name>].
  • Expanded README.md with a “Customizing Tile Layers and Overlays” section and updated backend configuration guidance.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/leaflet_options.js Adds extensive JSDoc, documents runtime env vars, and removes the unused baselayer export.
test/leaflet_options.test.js Updates assertions to use leafletOptions.layer[0][...] after baselayer removal.
README.md Documents base layers/overlays customization and clarifies backend configuration guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/leaflet_options.js
Comment on lines 370 to 372
function getDefaultLayer() {
return config.OSRM_DEFAULT_LAYER || 'streets';
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: Updated the JSDoc to accurately describe that this function only returns the configured value or 'streets' when unset. Key validation (and fallback for unrecognized values) happens at the call site via layerMap[getDefaultLayer()] || streets.

Comment thread src/leaflet_options.js
Comment on lines +86 to +90
* 1. `OSRM_MODES` — preferred JSON array of `{name, url, path?, profile?}` objects.
* Also accepts a plain array of URL strings (auto-named "Mode 1", "Mode 2", …).
* 2. `OSRM_BACKEND` — **deprecated** single-backend string. Emits a console warning.
* 3. Environment defaults — three public profiles (driving, bike, foot) in dev mode;
* same three profiles in Docker mode when neither env var is set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: parseModes() now honors an explicit mode.profile when provided. When not specified, it falls back to positional assignment (index 0 to driving, 1 to bike, 2 to foot). The JSDoc has also been updated to document this fallback behavior.

Comment thread src/leaflet_options.js Outdated
*
* | Variable | Default | Description |
* |------------------------|----------------------------------|-------------|
* | `OSRM_MODES` | (public OSRM services) | JSON array of `{name, url, path?, profile?}` routing backends. |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: The module-level table now reads 'profile defaults by position (driving → bike → foot)' and the code now honors an explicit when provided.

Honor explicit profile field in OSRM_MODES entries, falling back to
positional assignment. Fix getDefaultLayer() JSDoc to not claim
validation that this function does not perform.
@DennisOSRM DennisOSRM merged commit 66e0532 into gh-pages Jul 4, 2026
6 checks passed
@DennisOSRM DennisOSRM deleted the docs/leaflet-options-179 branch July 4, 2026 15:32
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.

osrm-frontend.js options need documenting

2 participants