Class RoadsApi


  • public class RoadsApi
    extends java.lang.Object
    The Google Maps Roads API identifies the roads a vehicle was traveling along and provides additional metadata about those roads, such as speed limits.

    See also: Roads API documentation.

    • Method Detail

      • snapToRoads

        public static PendingResult<SnappedPoint[]> snapToRoads​(GeoApiContext context,
                                                                LatLng... path)
        Takes up to 100 GPS points collected along a route, and returns a similar set of data with the points snapped to the most likely roads the vehicle was traveling along.
        Parameters:
        context - The GeoApiContext to make requests through.
        path - The collected GPS points as a path.
        Returns:
        Returns the snapped points as a PendingResult.
      • snapToRoads

        public static PendingResult<SnappedPoint[]> snapToRoads​(GeoApiContext context,
                                                                boolean interpolate,
                                                                LatLng... path)
        Takes up to 100 GPS points collected along a route, and returns a similar set of data with the points snapped to the most likely roads the vehicle was traveling along. Additionally, you can request that the points be interpolated, resulting in a path that smoothly follows the geometry of the road.
        Parameters:
        context - The GeoApiContext to make requests through.
        interpolate - Whether to interpolate a path to include all points forming the full road-geometry. When true, additional interpolated points will also be returned, resulting in a path that smoothly follows the geometry of the road, even around corners and through tunnels.
        path - The path to be snapped.
        Returns:
        Returns the snapped points as a PendingResult.
      • speedLimits

        public static PendingResult<SpeedLimit[]> speedLimits​(GeoApiContext context,
                                                              LatLng... path)
        Returns the posted speed limit for given road segments. The provided LatLngs will first be snapped to the most likely roads the vehicle was traveling along.

        Note: The accuracy of speed limit data returned by the Google Maps Roads API cannot be guaranteed. Speed limit data provided is not real-time, and may be estimated, inaccurate, incomplete, and/or outdated. Inaccuracies in our data may be reported through Google Maps Feedback.

        Parameters:
        context - The GeoApiContext to make requests through.
        path - The collected GPS points as a path.
        Returns:
        Returns the speed limits as a PendingResult.
      • speedLimits

        public static PendingResult<SpeedLimit[]> speedLimits​(GeoApiContext context,
                                                              java.lang.String... placeIds)
        Returns the posted speed limit for given road segments.

        Note: The accuracy of speed limit data returned by the Google Maps Roads API cannot be guaranteed. Speed limit data provided is not real-time, and may be estimated, inaccurate, incomplete, and/or outdated. Inaccuracies in our data may be reported through Google Maps Feedback.

        Parameters:
        context - The GeoApiContext to make requests through.
        placeIds - The Place ID of the road segment. Place IDs are returned by the snapToRoads(GeoApiContext, com.google.maps.model.LatLng...) method. You can pass up to 100 placeIds with each request.
        Returns:
        Returns the speed limits as a PendingResult.
      • snappedSpeedLimits

        public static PendingResult<SnappedSpeedLimitResponse> snappedSpeedLimits​(GeoApiContext context,
                                                                                  LatLng... path)
        Returns the result of snapping the provided points to roads and retrieving the speed limits.
        Parameters:
        context - The GeoApiContext to make requests through.
        path - The collected GPS points as a path.
        Returns:
        Returns the snapped points and speed limits as a PendingResult.
      • nearestRoads

        public static PendingResult<SnappedPoint[]> nearestRoads​(GeoApiContext context,
                                                                 LatLng... points)
        Takes up to 100 GPS points, and returns the closest road segment for each point. The points passed do not need to be part of a continuous path.
        Parameters:
        context - The GeoApiContext to make requests through.
        points - The sequence of points to be aligned to nearest roads
        Returns:
        Returns the snapped points as a PendingResult.