Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub Directions BLOCK w/ Mapbox
export default request => {
let xhr = require('xhr');
let query = require('codec/query_string');
let clientToken = 'YOUR_CLIENT_TOKEN';
let apiUrl = 'https://api.mapbox.com/directions/v5';
let profile = request.message.profile;
let lat1 = request.message.lat1;
let lng1 = request.message.lng1;
let lat2 = request.message.lat2;
let lng2 = request.message.lng2;
let queryParams = {
steps:true,
access_token: clientToken,
};
apiUrl += '/' + profile + '/';
apiUrl += lng1 + ',' + lat1 + ';';
apiUrl += lng2 + ',' + lat2;
let url = apiUrl + '?' + query.stringify(queryParams);
request.message.directions = url;
return request.ok();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment