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
- Service to enable:
roads.googleapis.com - Authentication: API key
- Get started: Set up Roads API
- Pricing: Roads API usage and billing
- Policies: Roads API policies
Roads API: related products
- Often used with: Geocoding API
Roads API: common mistakes
- Problem: Calling
speedLimitswith a path of sparse or arbitrary points returns awarningMessage("Input path is too sparse") and the speed limits may not match the intended segments. Fix: For arbitrary points, get place IDs fromnearestRoadsfirst and callspeedLimitswith thoseplaceIdvalues. See /maps/documentation/roads/speed-limits. - Problem:
speedLimitsreturns 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 withsnapToRoadsornearestRoads. 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 inpathwithin 300 m of each other. See /maps/documentation/roads/snap#path. - Problem: Calling
speedLimitson a project without Asset Tracking access returns HTTP 403PERMISSION_DENIED("Speed limits are not available for this project."). Fix: Speed Limits requires an Asset Tracking license (or a transitioned Premium Planmaps-asset-xxxproject); 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.
- Return a set of latitude/longitude coordinates that align with road segments and most closely match the path of a set of specified coordinates.
- Return a set of latitude/longitude coordinates for the road segment closest to a set specified coordinates.
- Return the Google place identifier for the road segment closest to a set of latitude/longitude coordinates.
- Return the speed limit of the road segment that most closely matches the path of a set of latitude/longitude coordinates. Note: Requires an Asset Tracking license.
- Return the speed limit of the road segment for a provided Google place identifier. Note: Requires an Asset Tracking license.