This is the documentation of version 1.0.0-rc.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Function findBestWaypointInsertionIndices

    • The multi-waypoint variant of findBestWaypointInsertionIndex.

      It projects every existing and new waypoint onto the route exactly once, then returns one insertion slot per new waypoint. The i-th index is the slot in existingWaypoints where the i-th new waypoint falls by its along-route location. Slot 0 is before the origin, and slot existingWaypoints.length is after the destination.

      Several new waypoints may share a slot. To also merge them into the existing array in along-route order, use withInsertedWaypoints, which ranks them within each slot.

      Parameters

      • route: Route

        The existing calculated route, a Feature with LineString geometry.

      • existingWaypoints: WaypointLike[]

        The existing waypoints in order, from origin through intermediate waypoints to destination.

      • newWaypoints: WaypointLike[]

        The waypoints to find insertion slots for.

      Returns number[]

      The insertion slot indices, one per new waypoint, in input order.

      • An empty newWaypoints returns an empty array.
      • If the route geometry is empty or there are fewer than 2 existing waypoints, every new waypoint gets 0, so they would all prepend.
      • A new waypoint whose projection has no resolvable along-route location also gets 0, as in findBestWaypointInsertionIndex.