Roads API quick reference

The Roads API is an HTTPS web service that takes latitude/longitude coordinates (or, for Speed Limits, road-segment place IDs) and returns the roads a vehicle most likely traveled (Snap to Roads), the nearest road segments (Nearest Roads), and posted speed limits (Speed Limits), with a place ID for each road segment.

Roads API: key facts

  • Product: Roads API
  • Also known as: Google Maps Roads API, Roads API 1.0
  • Category: Routes
  • Platform: Web service (REST)
  • Runs on: Server (backend code)
  • Launch stage: GA
  • Lifecycle: Active
  • Overview: Roads API overview

Roads API: when to use it

Use Roads API when:

  • You need to snap a sequence of GPS points (up to 100 per request) to the roads a vehicle most likely traveled, optionally interpolating the road geometry.
  • You need the nearest road segment and its place ID for independent GPS points that don't form a continuous path.
  • You need the posted automobile speed limit for road segments and have an Asset Tracking license (Speed Limits has limited access).

Roads API: setup

Roads API: common mistakes

  • Problem: Calling speedLimits with a path of sparse or arbitrary points returns a warningMessage ("Input path is too sparse") and the speed limits may not match the intended segments. Fix: For arbitrary points, get place IDs from nearestRoads first and call speedLimits with those placeId values. See /maps/documentation/roads/speed-limits.
  • Problem: speedLimits returns no entry for a place ID that isn't a road segment (for example, a bridge's place ID), so the response can silently have fewer or no speed limits. Fix: Pass only road-segment place IDs, retrieved with snapToRoads or nearestRoads. See /maps/documentation/roads/speed-limits.
  • Problem: Snapped paths look jagged or off the road at high zoom when coordinates are stored at fewer than 7 decimal places or encoded as polylines (5-decimal precision), or when map tiles update after snapping. Fix: Store snapped latitude/longitude at 7 decimal places and don't use encoded polylines for high-zoom display. If neither precision issue applies, the map tiles may have changed since the path was snapped; re-snap old paths just before showing them. See /maps/documentation/roads/errors.
  • Problem: Points sampled at long intervals (for example, every 60 seconds) or placed sparsely produce gaps or unsnapped points in the snapped path. Fix: Sample vehicle locations every 1-10 seconds. See /maps/documentation/roads/errors.
  • Problem: Paths where consecutive points are too far apart can cause odd snapping behavior in snapToRoads, especially across GPS signal loss or noise. Fix: Keep consecutive points in path within 300 m of each other. See /maps/documentation/roads/snap#path.
  • Problem: Calling speedLimits on a project without Asset Tracking access returns HTTP 403 PERMISSION_DENIED ("Speed limits are not available for this project."). Fix: Speed Limits requires an Asset Tracking license (or a transitioned Premium Plan maps-asset-xxx project); contact sales to enable Asset Tracking. See /maps/documentation/roads/speed-limits.

What you can do with Roads API

See the guides linked below for each task, or compare across products in the Capabilities Explorer.