TomTom Maps for JavaScript
    Preparing search index...

    Function asSoftWaypoint

    • Creates a soft waypoint with a flexible radius for route calculation.

      A soft waypoint allows the routing algorithm to find the optimal path within a specified radius of the target location, rather than forcing the route to pass through the exact point. This is useful for:

      • Allowing the router to stay on major roads instead of detouring
      • Creating more efficient routes when exact location isn't critical
      • Simulating "pass near" behavior in route planning

      The resulting waypoint is a GeoJSON Point Feature with a radiusMeters property that the routing service uses to optimize the path.

      Parameters

      • hasLngLat: HasLngLat

        The location to extract coordinates from. Can be a coordinate array, Point geometry, or Point Feature.

      • radiusMeters: number

        The radius in meters within which the route can pass. The routing service will find the optimal point within this radius.

      Returns Waypoint

      A waypoint Feature with the radiusMeters property set.

      // Create a soft waypoint from coordinates
      // Route can pass anywhere within 500m of this point
      const softWaypoint = asSoftWaypoint([4.9, 52.3], 500);

      // Use in route calculation
      const route = await calculateRoute({
      key: 'your-api-key',
      locations: [
      [4.9, 52.3], // Hard waypoint (exact location)
      asSoftWaypoint([5.1, 52.5], 1000), // Soft waypoint (within 1km)
      [5.3, 52.7] // Hard waypoint (exact location)
      ]
      });

      // Create soft waypoint from a Place Feature
      const place = await geocode({ key: 'your-api-key', query: 'Amsterdam' });
      const softPlace = asSoftWaypoint(place, 2000);
      // Route will pass within 2km of Amsterdam center