Method: GoogleMapsService::Apis::Roads#snapped_speed_limits

Defined in:
lib/google_maps_service/apis/roads.rb

#snapped_speed_limits(path) ⇒ Hash

Returns the posted speed limit (in km/h) for given road segments.

The provided points will first be snapped to the most likely roads the vehicle was traveling along.

Examples:

Multi points snap

path = [
    [-33.8671, 151.20714],
    [-33.86708, 151.20683000000002],
    [-33.867070000000005, 151.20674000000002],
    [-33.86703, 151.20625]
]
results = client.snapped_speed_limits(path)

Parameters:

  • path (Hash, Array)

    The path of points to be snapped. A list of (or single) latitude/longitude tuples.

Returns:

  • (Hash)

    A hash with both a list of speed limits and a list of the snapped points.

[View source]

94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/google_maps_service/apis/roads.rb', line 94

def snapped_speed_limits(path)
  path = GoogleMapsService::Convert.waypoints(path)

  params = {
    path: path
  }

  return get('/v1/speedLimits', params,
             base_url: ROADS_BASE_URL,
             accepts_client_id: false,
             custom_response_decoder: method(:extract_roads_body))
end