Skip to content

Add native iOS routing via MapKit MKDirections #11

Description

@jkasprzyk17

Context

MapViewDirections (#7) uses the Google Directions API, which requires an API key and billing. On iOS, MapKit provides native routing via MKDirections with no Google dependency — useful for apps that default to Apple Maps (provider="apple" after #1) or want to avoid Directions API costs on iOS.

react-native-maps-directions is Google-only. This issue adds an optional native routing path as a differentiator for @nitro-maps/directions.

Goal

Allow MapViewDirections to compute routes using MapKit on iOS when configured:

<MapViewDirections
  origin={origin}
  destination={destination}
  routingProvider="mapkit"  // or auto-detect from MapView provider
  mode="DRIVING"
  onReady={({ coordinates, distance, duration }) => {  }}
/>

Scope

  • Define routing provider strategy:
    • routingProvider?: 'google' | 'mapkit' | 'auto'
    • auto: use MapKit on iOS when MapView uses Apple provider; Google elsewhere
  • Implement iOS native module or Nitro hybrid (evaluate lightest approach):
    • wrap MKDirections / MKDirections.Request
    • support transport types mapping to mode where possible (automobile, walking, transit)
    • return decoded route polyline as Coordinate[]
    • return distance (meters → km) and expected travel time (seconds → minutes) for onReady parity
  • Wire native adapter into @nitro-maps/directions fetch layer behind shared interface.
  • Handle errors: no route found, network unavailable, unsupported transport type.
  • Document platform limitations:
    • MapKit only on iOS
    • transit details may differ from Google
    • waypoints support per MKDirections capabilities
  • Add example app toggle: Google Directions vs MapKit (iOS simulator).

Out of scope

Acceptance criteria

Implementation notes

Prefer a thin Nitro spec if other native routing adapters are planned (#1 multi-provider). Otherwise a minimal MKDirectionsModule may suffice for v1.

Shared interface sketch:

interface RoutingAdapter {
  fetchRoute(request: RouteRequest): Promise<RouteResult>;
}

Notes

Depends on #6 and #7. Can ship after Google Directions parity (#7#9). Optional for v1.0 — Google-only directions may ship first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions