Skip to content

feat: add geo: URI link on document map box#4565

Open
Sixtedsm wants to merge 1 commit into
c2corg:masterfrom
Sixtedsm:add-geo-uri-link
Open

feat: add geo: URI link on document map box#4565
Sixtedsm wants to merge 1 commit into
c2corg:masterfrom
Sixtedsm:add-geo-uri-link

Conversation

@Sixtedsm
Copy link
Copy Markdown

@Sixtedsm Sixtedsm commented May 12, 2026

What

Adds a button next to the GPX/KML download buttons on the document map box. On mobile, tapping it opens the document's location in the user's preferred map app (Google Maps, OsmAnd, Maps.me, Organic Maps, Plans, etc.) via a geo: URI (RFC 5870).

Why

Requested on the forum by community members: https://forum.camptocamp.org/t/application-camptocamp-cahier-des-charges-a-elaborer-avec-vous/308792

Currently, to navigate to a waypoint or trailhead from camptocamp.org on a phone, users have to copy coordinates manually or download the GPX and import it elsewhere. This adds a one-tap path that integrates with whatever map app the user already uses.

Scope

  • One file modified: src/views/document/utils/boxes/MapBox.vue
  • ~25 lines added, no dependencies, no API changes
  • Button only renders on mobile ($screen.isMobile) and only when the document has a Point geometry
  • Falls back gracefully (returns null, button is hidden) if geometry is missing or malformed
  • Uses ol.proj.toLonLat to convert from the internal EPSG:3857 projection to WGS84 expected by the geo: URI scheme

How to test

  1. npm run serve
  2. Open DevTools, toggle device toolbar (Ctrl+Shift+M), pick a mobile device profile
  3. Navigate to any waypoint, e.g. http://localhost:8080/waypoints
  4. The new pin icon appears next to the GPX / KML buttons under the map
  5. Inspect the <a> element — the href is geo:LAT,LON?q=LAT,LON with 6-decimal precision (≈10 cm)
  6. On a real mobile device, tapping the button opens the OS's "Open with..." dialog with installed map apps

Notes

The geo: URI scheme has no handler on desktop browsers — the button is intentionally hidden there (v-if="... && $screen.isMobile") to keep the UI clean.

Summary by CodeRabbit

  • New Features
    • Mobile users can now open location data directly in their device's default map application via a new "Open this location in your map app" button, available when location information is present.

Review Change Stack

Adds a button next to the GPX/KML buttons that opens the document
location in the user's preferred mobile map app via a geo: URI
(RFC 5870). Only appears on mobile and only when the document has
a Point geometry.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label May 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Walkthrough

MapBox component adds a mobile-only button that opens the document location in a native map app. A new geoUri() computed property parses document geometry as a Point, converts coordinates to lon/lat, and returns a geo: deep-link URI; the template conditionally renders the button only on mobile when the URI is available.

Changes

Mobile geo deep-link

Layer / File(s) Summary
Mobile map-app button and geo URI generation
src/views/document/utils/boxes/MapBox.vue
geoUri() computed property validates and converts document geometry to a geo: deep-link with lon/lat coordinates. Template conditionally renders a mobile-only anchor button linked to this URI, visible only when the location is available and the app is on mobile.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A map link for the mobile few,
Geo coordinates shining through,
With deep-links bright and templates neat,
We guide your paws to places sweet!
~🌍✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add geo: URI link on document map box' is clear, concise, and directly describes the main change—adding a geo: URI link feature to the MapBox component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/views/document/utils/boxes/MapBox.vue`:
- Around line 116-120: The code currently only checks
Array.isArray(parsed.coordinates) and can produce geo:NaN URIs; update the guard
in the MapBox.vue logic that builds the URI (the block referencing parsed.type,
parsed.coordinates and ol.proj.toLonLat) to validate coordinates thoroughly:
require parsed.type === 'Point', ensure parsed.coordinates is an array with at
least two items, confirm the first two entries are numeric (Number.isFinite)
before calling ol.proj.toLonLat, and after converting validate that lon and lat
are finite numbers; if any check fails return null. This targets the
parsed.type/parsed.coordinates checks and the ol.proj.toLonLat result to prevent
generating geo:NaN URIs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e09725c-7a71-4edf-ad41-878199ada511

📥 Commits

Reviewing files that changed from the base of the PR and between a77216a and 77eac8b.

📒 Files selected for processing (1)
  • src/views/document/utils/boxes/MapBox.vue

Comment on lines +116 to +120
if (parsed.type !== 'Point' || !Array.isArray(parsed.coordinates)) {
return null;
}
const [lon, lat] = ol.proj.toLonLat(parsed.coordinates);
return `geo:${lat.toFixed(6)},${lon.toFixed(6)}?q=${lat.toFixed(6)},${lon.toFixed(6)}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard malformed coordinate values before building the URI.

Line 116–120 only checks that coordinates is an array; malformed values can still generate geo:NaN,NaN... and show a broken button instead of returning null.

Suggested fix
-      if (parsed.type !== 'Point' || !Array.isArray(parsed.coordinates)) {
+      if (parsed.type !== 'Point' || !Array.isArray(parsed.coordinates) || parsed.coordinates.length < 2) {
         return null;
       }
-      const [lon, lat] = ol.proj.toLonLat(parsed.coordinates);
+      const [x, y] = parsed.coordinates;
+      if (!Number.isFinite(x) || !Number.isFinite(y)) {
+        return null;
+      }
+      const [lon, lat] = ol.proj.toLonLat([x, y]);
+      if (!Number.isFinite(lon) || !Number.isFinite(lat)) {
+        return null;
+      }
       return `geo:${lat.toFixed(6)},${lon.toFixed(6)}?q=${lat.toFixed(6)},${lon.toFixed(6)}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (parsed.type !== 'Point' || !Array.isArray(parsed.coordinates)) {
return null;
}
const [lon, lat] = ol.proj.toLonLat(parsed.coordinates);
return `geo:${lat.toFixed(6)},${lon.toFixed(6)}?q=${lat.toFixed(6)},${lon.toFixed(6)}`;
if (parsed.type !== 'Point' || !Array.isArray(parsed.coordinates) || parsed.coordinates.length < 2) {
return null;
}
const [x, y] = parsed.coordinates;
if (!Number.isFinite(x) || !Number.isFinite(y)) {
return null;
}
const [lon, lat] = ol.proj.toLonLat([x, y]);
if (!Number.isFinite(lon) || !Number.isFinite(lat)) {
return null;
}
return `geo:${lat.toFixed(6)},${lon.toFixed(6)}?q=${lat.toFixed(6)},${lon.toFixed(6)}`;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/views/document/utils/boxes/MapBox.vue` around lines 116 - 120, The code
currently only checks Array.isArray(parsed.coordinates) and can produce geo:NaN
URIs; update the guard in the MapBox.vue logic that builds the URI (the block
referencing parsed.type, parsed.coordinates and ol.proj.toLonLat) to validate
coordinates thoroughly: require parsed.type === 'Point', ensure
parsed.coordinates is an array with at least two items, confirm the first two
entries are numeric (Number.isFinite) before calling ol.proj.toLonLat, and after
converting validate that lon and lat are finite numbers; if any check fails
return null. This targets the parsed.type/parsed.coordinates checks and the
ol.proj.toLonLat result to prevent generating geo:NaN URIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant