Repository navigation
Maintenance: geolocation fallback, token handling, a11y and docs - #1
Merged
Merged
Conversation
Previously the map was only created inside the geolocation success callback, so denying the permission, ignoring the prompt, or opening the page on a non-HTTPS origin left a blank page. The map is now created immediately with a world view and re-centred on the user's position when it becomes available (10s timeout).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the SweetAlert2 global and ensure the no-script fallback is visible.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Improves geolocation fallback behavior, accessibility, token handling, metadata, and documentation for the map application.
Changes:
- Initializes the map before geolocation resolves or fails.
- Adds accessibility markup, metadata, and no-script messaging.
- Centralizes the Mapbox token and expands setup guidance.
| File | Summary |
|---|---|
style.css |
Adds visually hidden heading styling. |
README.md |
Documents usage, structure, setup, and token restrictions. |
main.js |
Adds fallback map initialization and centralized token handling. Moderate issue (1 vote): use Swal.fire(...) instead of swal(...) for SweetAlert2 v11 compatibility. |
index.html |
Adds metadata, accessibility markup, and no-script messaging. Moderate issue (4 votes): make the no-script message visible without scrolling past the full-height map. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+22
to
+23
| <div id='map' role="region" aria-label="Interactive map with driving directions"></div> | ||
| <noscript>This app needs JavaScript enabled to display the map and calculate distances.</noscript> |
This branch was successfully deployed
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.

Summary
TypeErrorwherenavigator.geolocationis undefined). The map now renders immediately with a world view and re-centres on the user when a position arrives (10s timeout).button: "OK"is a SweetAlert v1 option. SweetAlert2 warns "Unknown parameter" and ignores it. Replaced it withconfirmButtonText.MAPBOX_ACCESS_TOKEN, with a comment about URL restriction.mainlandmark, a visually hiddenh1, a labelled map region and a<noscript>message.descriptionandtheme-color.main.jsis an ES module, and geolocation needs HTTPS or localhost), the file layout and Mapbox token guidance.Action needed from the owner: Mapbox token
The token in
main.jsis a publicpk.token, not a secretsk.token. It is meant to be visible in browser code, but it has been in the public git history and anyone can reuse it. Please:https://location-distance-calculator.vercel.app(andhttp://localhostif you develop locally).MAPBOX_ACCESS_TOKEN, then delete the old one.This PR does not change the token value.
Verification
node --check main.jspasses.main.jsin a Nodevmharness with stubbedmapboxgl,MapboxDirections,swalandnavigator:jumpTothe user's coordinates at zoom 9navigator.geolocation: map created, then an info dialog. Before this change:TypeError.defaultParamsof the sweetalert2@11 bundle).style.css,main.js,LICENSE) exist. CRLF line endings are preserved.Deliberately not changed