Skip to content

Add MapViewDirections advanced routing — waypoints, modes, traffic, split routes #8

Description

@jkasprzyk17

Context

The core MapViewDirections component (#7) covers origin → destination routing. react-native-maps-directions also supports advanced Google Directions options that many production apps rely on: multi-stop routes, travel modes, traffic-aware ETAs, waypoint optimization, and automatic route splitting when waypoint limits are exceeded.

Reference props: https://github.com/bramus/react-native-maps-directions#props

Goal

Reach feature parity with react-native-maps-directions advanced routing props:

<MapViewDirections
  origin={origin}
  destination={destination}
  waypoints={stops}
  mode="DRIVING"
  language="pl"
  optimizeWaypoints
  splitWaypoints
  timePrecision="now"
  precision="high"
  resetOnChange={false}
  apiKey={GOOGLE_MAPS_APIKEY}
/>

Scope

  • Waypointswaypoints?: (Coordinate | string)[] between origin and destination.
  • Travel modemode?: 'DRIVING' | 'BICYCLING' | 'WALKING' | 'TRANSIT' (default 'DRIVING').
  • Languagelanguage?: string (default 'en').
  • Region biasregion?: string for string-based locations.
  • Waypoint optimizationoptimizeWaypoints?: boolean (document higher Google billing tier).
  • Split waypointssplitWaypoints?: boolean to bypass 10/25 waypoint limits by splitting into multiple API requests and merging polylines.
  • Traffic / timetimePrecision?: 'none' | 'now' for realtime traffic duration.
  • Polyline precisionprecision?: 'high' | 'low':
    • high — full step-level polyline detail
    • low — overview polyline (smoothed, better performance)
  • Reset behaviorresetOnChange?: boolean (default true); when false, keep previous polyline visible while refetching to avoid glitching.
  • Channelchannel?: string for Google API reporting.
  • Custom base URLdirectionsServiceBaseUrl?: string (default Google JSON endpoint).
  • Pass waypointOrder from API response through onReady.
  • Pass fare object through onReady when returned (transit).
  • Document billing implications for optimizeWaypoints, splitWaypoints, and timePrecision: 'now'.

Out of scope

Acceptance criteria

  • Route with 2+ waypoints renders correctly.
  • mode, language, and region are forwarded to the Directions API.
  • optimizeWaypoints: true returns reordered waypointOrder in onReady.
  • splitWaypoints: true handles >10 waypoints without API failure (multiple segments merged).
  • timePrecision: 'now' affects duration when traffic data is available.
  • precision: 'high' produces denser coordinate arrays than 'low'.
  • resetOnChange: false avoids polyline flicker during refetch.
  • Props and callback shapes match react-native-maps-directions documentation where applicable.
  • Unit tests for waypoint splitting and query param construction.

Notes

Depends on #6 (package) and #7 (core fetch/render). Align prop names with react-native-maps-directions for easier migration (apikey alias optional).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions