If you're building a traffic map, the last thing you want is to parse a proprietary format and convert coordinates. Road511's GeoJSON endpoints return standard FeatureCollections that drop directly into Leaflet, Mapbox, MapLibre, ArcGIS, QGIS, or any GeoJSON-compatible tool.
GeoJSON Endpoints
Every list endpoint in Road511 has a /geojson variant:
GET /api/v1/events/geojson
GET /api/v1/features/geojson?type=cameras
GET /api/v1/truck/corridor/geojson
All return Content-Type: application/geo+json with a standard FeatureCollection.
Bounding Box Query
Show events in the current map viewport:
const bounds = map.getBounds();
const bbox = [
bounds.getWest(), bounds.getSouth(),
bounds.getEast(), bounds.getNorth()
].join(',');
const res = await fetch(
`https://api.road511.com/api/v1/events/geojson?bbox=${bbox}&status=active`,
{ headers: { 'X-API-Key': key } }
);
const geojson = await res.json();
L.geoJSON(geojson).addTo(map);
Radius Search
Find everything within 50km of a point:
curl "https://api.road511.com/api/v1/events/geojson?lat=34.05&lng=-118.24&radius_km=50&status=active" \
-H "X-API-Key: your_key"
Multiple Feature Types
Build a layered map with different feature types:
const types = ['cameras', 'signs', 'weather_stations', 'rest_areas'];
for (const type of types) {
const res = await fetch(
`https://api.road511.com/api/v1/features/geojson?type=${type}&jurisdiction=CA`,
{ headers: { 'X-API-Key': key } }
);
const geojson = await res.json();
L.geoJSON(geojson, {
pointToLayer: (f, latlng) => L.marker(latlng, { icon: icons[type] })
}).addTo(layerGroups[type]);
}
LineString Geometry
Not everything is a point. Construction events, truck routes, and weight restrictions include polyline geometry:
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [[-87.63, 41.88], [-87.62, 41.89], [-87.60, 41.90]]
},
"properties": {
"id": "fhwa-il-staa-001",
"feature_type": "truck_routes",
"name": "I-90 STAA National Network"
}
}
Spatial Queries Under the Hood
Road511 uses PostGIS for all spatial operations. Every feature has a geometry column with a spatial index. Bounding box queries use ST_Intersects, radius queries use ST_DWithin on geography. The truck corridor endpoint builds a buffer geometry with ST_Buffer and intersects it against all truck-related features.
Try It
- Live map — built entirely on Road511's GeoJSON endpoints
- API docs
- Free API key
- Code examples
Top comments (0)