External APIs

Mapbox: Directions

Turn-by-turn traffic-aware directions and ETAs, including driving, walking, and cycling
Back to BLOCKS

About Mapbox: Directions

Mapbox's Directions provides a variety of traffic-aware navigation features, including walking, driving, and cycling directions, ETAs, alternative routes, and turn-by-turn instructions, all laid upon Mapbox's beautiful selection of vector maps.

The Mapbox Directions block, you can build traffic-aware directions and navigation into your realtime applications. For example, if you're building a taxi or ridesharing application, the block lets you stream geolocation coordinates data between users (like a driver and passenger), then provide navigation to connect them. Or for a delivery app, you can send drop off locations to a fleet of trucks based on their current coordinates.

Try it Now
Categories:
External APIs External APIs
Charting & Graphing
Charting & Graphing
Geolocation
Geolocation
Last Updated:
20160919 at 23:12:11
Author:
PubNub

Walkthrough

The block requires five inputs: two pairs of latitude, longitude and the type of desired transportation method. Once the response comes from Mapbox, the block appends the directions into the message payload.

Input

Input Channel: mapbox-directions-channel (configurable)lat1, lng1 is the origin coordinateslat2, lng2 is the destination coordinatesprofile represents the type of transporation: mapbox/driving, mapbox/cycling or mapbox/walking
{
    "lat1": 10,
    "lng1": 11,
    "lat2": 15,
    "lng2": 20,
    "profile": "mapbox/driving"
}

Output

The block appends the directions returned by the Mapbox Directions API into the message payload. Please refer to the Mapbox documentation for field information.
{
    "lat1": 10,
    "lng1": 11,
    "lat2": 15,
    "lng2": 20,
    "profile": "mapbox/driving",
    "directions": <Mapbox Directions API Response>
}

Try PubNub Today

Connect up to 100 devices for Free