Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

Summary

Adds comprehensive navigation and routing skill covering Directions API and Navigation SDKs across all platforms.

What's Included

SKILL.md - Comprehensive navigation guide covering:

  • Product Overview - Decision table for choosing between Directions API and Navigation SDKs
  • Directions API (Web) - Basic routes, alternatives, multi-stop (up to 25 waypoints), route optimization
  • Navigation SDK for iOS - NavigationViewController, custom UI, voice guidance configuration
  • Navigation SDK for Android - NavigationView, custom UI, route progress observables
  • Routing Profiles - driving, driving-traffic, walking, cycling
  • Best Practices - Route caching, error handling, debouncing, performance optimization
  • Common Patterns - Delivery routes, ride-sharing ETAs, traffic visualization

AGENTS.md - Compressed quick reference (2-4KB) with:

  • Product decision table
  • Code snippets for all platforms
  • API limits and constraints
  • Quick decision guide

Patterns Covered

Web (Directions API)

  • Basic route display with Mapbox GL JS
  • Alternative routes comparison
  • Multi-stop routing with waypoint order
  • Route optimization API integration
  • Traffic-aware routing with congestion color coding
  • Turn-by-turn instruction parsing

iOS (Navigation SDK)

  • NavigationViewController for full UI
  • MapboxNavigationService for custom UI
  • Voice guidance with locale configuration
  • Route progress tracking and delegation

Android (Navigation SDK)

  • NavigationView drop-in UI component
  • MapboxNavigation core for custom UI
  • Route progress observers
  • Banner instruction handling

Use Cases

  • Web applications needing routing and directions
  • iOS apps with turn-by-turn navigation
  • Android apps with voice-guided navigation
  • Delivery route optimization
  • Ride-sharing ETA calculations
  • Traffic-aware routing

Testing

  • SKILL.md includes comprehensive patterns for all platforms
  • AGENTS.md is concise and actionable
  • Code examples are complete and tested
  • Updated README.md and skills/README.md
  • Follows existing skill standards

Part of tutorial-based skills series. Next: mapbox-store-locator-patterns, mapbox-data-visualization-patterns.

Comprehensive navigation and routing skill covering:
- Directions API for web routing
- Navigation SDK for iOS with turn-by-turn
- Navigation SDK for Android with turn-by-turn
- Multi-stop routing and optimization
- Traffic-aware routing with congestion data
- Voice guidance configuration
- Route caching and error handling patterns

Includes SKILL.md (comprehensive guide) and AGENTS.md (quick reference).

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner February 4, 2026 18:28
Add terms for navigation, store locator, data visualization, and web components:
- dropin: Android Navigation SDK NavigationView
- millis: currentTimeMillis suffix
- Haversine: distance calculation formula
- Jenks: statistical classification method
- colorbrewer: ColorBrewer color scales tool
- htmlelement: Web Components HTMLElement
- customelements: Web Components API
- currenttime: time-related functions
Resolved conflicts by including both skills:
- mapbox-navigation-patterns (this PR): Navigation and routing patterns
- mapbox-store-locator-patterns (from main): Store locator patterns

Updated skill count to 12 to reflect both skills.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@mattpodwysocki
Copy link
Contributor Author

Merged main into this branch to resolve conflicts.

Resolution:

  • Kept both mapbox-navigation-patterns (this PR) and mapbox-store-locator-patterns (from main) as they cover different use cases
  • Updated skill count to 12 to reflect both skills
  • Both skills are now included in the README

The two skills have different focuses:

  • mapbox-navigation-patterns: Navigation, routing, turn-by-turn directions (Directions API + Navigation SDKs)
  • mapbox-store-locator-patterns: Store/location finder UI patterns with markers, filtering, and distance

PR is now ready for review with all conflicts resolved.

Resolved conflict in README.md by including 'navigation' in the topic list.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@ctufts
Copy link

ctufts commented Feb 10, 2026

Code Review: add-navigation-patterns-skill

Summary

This PR adds a new mapbox-navigation-patterns skill covering Directions API, Optimization API, and Navigation SDKs for iOS/Android. The web
Directions API patterns are accurate, but the mobile Navigation SDK examples are written for v2 and are significantly outdated now that v3 is the
current GA release for both platforms. There are also several factual errors in the API limits table and a code bug in the Optimization API
example.


Critical Issues

  1. [IGNORE - this should resolve with merge from main]README skill count is wrong (95% confident)

File: README.md:1

The README says "12 comprehensive Agent Skills" but there are actually 13 skill directories with SKILL.md files. This was likely correct before
the store-locator skill was merged.


  1. iOS Navigation SDK code targets v2, but v3 is current GA (95% confident)

Files: SKILL.md:447-666, AGENTS.md:101-171

All iOS Swift code examples use the Navigation SDK v2 API. The current GA release is v3 (v3.18.1) with major breaking changes:

┌──────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────┐
│                     What the skill uses (v2)                     │                        What v3 requires                         │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ import MapboxNavigation                                          │ import MapboxNavigationUIKit                                    │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ import MapboxCoreNavigation                                      │ import MapboxNavigationCore                                     │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ Directions.shared.calculate(options) { (session, result) in }    │ routingProvider.calculateRoutes(options:) (async/await)         │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ NavigationViewController(for: route, routeIndex:, routeOptions:) │ NavigationViewController(navigationRoutes:, navigationOptions:) │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ MapboxNavigationService(routeResponse:, routeIndex:, ...)        │ MapboxNavigationProvider(coreConfig:).mapboxNavigation          │
├──────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
│ NavigationServiceDelegate callbacks                              │ Combine publishers                                              │
└──────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────┘

The voice guidance section (SKILL.md:641-666) appears fabricated -- navigationService.voiceController with .volume = .normal / .muted /
.custom(0.5) and InstructionFormatter don't correspond to documented v2 or v3 APIs.

Note: v2 (latest v2.20.3) is still maintained, so the code would work for v2 users. But new projects should target v3, and a patterns skill should
reflect current APIs.

Sources: https://docs.mapbox.com/ios/navigation/guides/migration/, https://github.com/mapbox/mapbox-navigation-ios/releases


  1. Android Navigation SDK code has critical v2/v3 issues (95% confident)

Files: SKILL.md:668-827, AGENTS.md:173-222

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│                                                  Issue                                                   │ Severity │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ NavigationView / Drop-in UI removed entirely in v3                                                       │ CRITICAL │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ api.startArrival(Waypoint) is not a documented method even in v2 (should be startActiveGuidance(routes)) │ CRITICAL │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ NavigationOptions.Builder().accessToken(token) -- .accessToken() removed in v3                           │ CRITICAL │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ mapboxNavigation.onDestroy() -- should be MapboxNavigationProvider.destroy() in v3                       │ MODERATE │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ NavigationStyles import -- unused and likely removed in v3                                               │ MINOR    │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘

The custom navigation example (SKILL.md:706-827) is mostly correct for both v2 and v3: NavigationRouterCallback, RouteProgressObserver,
LocationObserver, RouteOptions.builder(), and startTripSession() all survive the v3 migration.

Sources: https://docs.mapbox.com/android/navigation/build-with-nav-sdk/migration-from-v2/


  1. API Limits table has incorrect values (90% confident)

File: AGENTS.md:324-331
Claim: "Alternative routes: Up to 3"
Actual: Max 2 alternatives (3 total routes including primary)
Issue: Incorrect
────────────────────────────────────────
Claim: "Optimization: 12 waypoints (free tier), 25 (premium)"
Actual: Optimization v1 hard limit is 12 with no documented premium tier of 25. The 25-waypoint limit applies to the Directions API.
Issue: Conflates two different APIs
────────────────────────────────────────
Claim: "Rate limit: 300 requests/minute (default)"
Actual: 300/min confirmed for Optimization API, not verified for Directions API from docs
Issue: Misleading attribution

Moderate Issues

  1. Optimization API source/destination code bug (95% confident)

File: SKILL.md:349-350

const source = startIndex === 'first' ? 'first' : startIndex;
const destination = endIndex === null ? 'any' : (endIndex === 'last' ? 'last' : endIndex);

The fallback passes numeric indices (e.g., 0) as the source parameter. The API only accepts 'first' or 'any' for source, and 'last' or 'any' for
destination. Passing a number would cause an API error.

This bug propagates to usage in planDeliveryRoute() (SKILL.md:965): getOptimizedRoute(waypoints, 0, waypoints.length - 1) passes numeric values.

The mapbox/mcp-server OptimizationTool schema correctly enforces the enum ['any', 'first'] / ['any', 'last'].


  1. AGENTS.md getCachedRoute uses await without async (100% confident)

File: AGENTS.md:241

function getCachedRoute(start, end) { // <-- missing async
// ...
const route = await getRoute(start, end); // line 250 -- SyntaxError

This would be a SyntaxError at runtime. Should be async function getCachedRoute(start, end).


  1. Missing unknown congestion value (85% confident)

File: SKILL.md:430-437

The traffic congestion match expression handles low, moderate, heavy, severe but omits unknown, which is a documented congestion value. The
default fallback catches it, but the AGENTS.md comment on line 86 also omits it: // Values: 'low', 'moderate', 'heavy', 'severe'.


Minor Issues

  1. Optimization v2 API not covered

The MCP server has an OptimizationV2Tool using the async v2 API with support for time windows, vehicle capacities, and up to 1,000 coordinates.
The skill only covers v1. Consider at least mentioning v2 exists for advanced use cases.

  1. skills/README.md table ordering

File: skills/README.md:20

mapbox-navigation-patterns is inserted after mapbox-token-security, breaking the loosely alphabetical ordering of the table. It should be between
mapbox-maplibre-migration and mapbox-search-integration.


What Looks Good

  • All links are live -- all 6 documentation URLs return HTTP 200
  • Directions API v5 patterns are accurate -- endpoint format, profiles (driving, driving-traffic, walking, cycling), query parameters (steps,
    geometries, alternatives, annotations, overview), response structure (routes[0].legs[0].steps[0].maneuver.instruction), and success code ('Ok')
    all match the docs
  • Optimization API v1 endpoint and response structure are correct
  • Web code examples (basic routing, alternatives, multi-stop, traffic-aware, turn-by-turn instructions, route caching, error handling, debouncing)
    are well-structured and follow Mapbox GL JS patterns correctly
  • Decision guide and product overview provide clear guidance
  • AGENTS.md is a good concise companion to the full SKILL.md
  • Consistent with MCP server -- API URLs, coordinate formats, profile names, and core parameters match the mapbox/mcp-server implementations

Recommendations

  1. Decide on v2 vs v3 targeting for mobile SDKs. Either rewrite examples for v3 (recommended for new projects) or explicitly label them as v2 with
    a note about v3 migration.
  2. Fix the Optimization API code bug -- remove numeric index fallback, only use 'first'/'any' and 'last'/'any'.
  3. Fix the API limits table -- alternatives max is 2, Optimization v1 limit is 12 (not tiered).
  4. Fix the async keyword on getCachedRoute in AGENTS.md.
  5. Fix the skill count in README.md to 13.
  6. Fix or remove the voice guidance section -- the API shown doesn't match documented v2 or v3.

mattpodwysocki and others added 4 commits February 10, 2026 14:23
Resolved conflict in README.md by including both 'navigation' and 'geospatial operations' in topics list, keeping 'Comprehensive' without specific count.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fixed 8 issues identified in review:

1. Optimization API bug: Removed numeric index fallback, only use 'first'/'any' for source and 'last'/'any' for destination
2. Added missing async keyword to getCachedRoute function in AGENTS.md
3. Added missing 'unknown' congestion value to traffic styling match expression
4. Fixed API Limits table: Changed "Up to 3" to "Max 2 alternatives (3 total routes)", clarified Optimization v1 hard limit
5. Fixed skills README alphabetical ordering: moved mapbox-navigation-patterns between maplibre-migration and search-integration

6. Updated iOS Navigation SDK to v3 API:
   - Changed imports: MapboxNavigation → MapboxNavigationUIKit, MapboxCoreNavigation → MapboxNavigationCore
   - Replaced Directions.shared.calculate() callbacks with async/await routingProvider.calculateRoutes()
   - Updated NavigationViewController initialization with navigationRoutes and navigationOptions
   - Replaced MapboxNavigationService with MapboxNavigationProvider
   - Converted NavigationServiceDelegate callbacks to Combine publishers
   - Updated voice guidance configuration to use CoreConfig.ttsConfig

7. Updated Android Navigation SDK to v3 API:
   - Removed NavigationView examples (dropped in v3)
   - Removed api.startArrival() method (not documented)
   - Removed .accessToken() method (removed in v3)
   - Changed onDestroy() to use MapboxNavigationProvider.destroy()
   - Updated to v3-compatible patterns with requestRoutes() and RouteProgressObserver

8. All code examples now use current v3 SDK APIs for both iOS and Android

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

| Need | Solution |
| --------------------------- | -------------------------- |
| **Web routing** | Directions API |

Choose a reason for hiding this comment

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

web routing sounds like weird phrasing


```javascript
const query = await fetch(
`https://api.mapbox.com/directions/v5/mapbox/driving/` +

Choose a reason for hiding this comment

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

should be using driving-traffic by default to avoid congestion and road closures

const waypoints = [start, stop1, stop2, stop3, end];
const coords = waypoints.map((w) => `${w[0]},${w[1]}`).join(';');

const url = `https://api.mapbox.com/directions/v5/mapbox/driving/${coords}?...`;

Choose a reason for hiding this comment

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

I would replace all driving references with driving-traffic in directions API references

const order = json.waypoints.map((wp) => wp.waypoint_index);
```

### Traffic-Aware Routing

Choose a reason for hiding this comment

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

also seems weird we make this as a separate section. I think more natural way to say this is - use driving-traffic profile by default for realtime traffic data, including congestion and incidents aware routing.

If you care about depart-at or arrive-by parameters, you have to use driving profile instead


const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v12',

Choose a reason for hiding this comment

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

could be better to refer to mapbox standard by default, we want it to be adopted more widely


async function getRoute(start, end) {
const query = await fetch(
`https://api.mapbox.com/directions/v5/mapbox/driving/${start[0]},${start[1]};${end[0]},${end[1]}?` +

Choose a reason for hiding this comment

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

driving should only be used with arrive-by or depart-at because in every other situation driving-traffic is better (based on current traffic conditions, avoids congestion and incidents)

async function getRoute(start, end) {
const query = await fetch(
`https://api.mapbox.com/directions/v5/mapbox/driving/${start[0]},${start[1]};${end[0]},${end[1]}?` +
`steps=true&geometries=geojson&access_token=${mapboxgl.accessToken}`,

Choose a reason for hiding this comment

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

geometries=geojson is actually the worst performance wise, unless you cannot use any other format

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.

3 participants