Menu

GeoJSON Traffic Events API with BBox and Radius Queries
🖼️

GeoJSON Traffic Events API with BBox and Radius Queries

DEV Community·Roman Kotenko·6 months ago
#HmPMZoVt
#geojson#api#javascript#webdev#type
Reading 0:00
15s threshold

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

Enter fullscreen mode

Exit fullscreen mode

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 ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.