How to use the @mapbox/mapbox-sdk/services/directions function in @mapbox/mapbox-sdk

To help you get started, we’ve selected a few @mapbox/mapbox-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stepankuzmin / WhiskyBar / src / utils.js View on Github external
// @flow
import mapboxDirections from '@mapbox/mapbox-sdk/services/directions';

import {
  MAPBOX_ACCESS_TOKEN,
  FOURSQUARE_CLIENT_ID,
  FOURSQUARE_CLIENT_SECRET,
  FOURSQUARE_API_URL
} from './config';

const directionsClient = mapboxDirections({ accessToken: MAPBOX_ACCESS_TOKEN });

// https://developer.foursquare.com/docs/api/venues/search
// https://developer.foursquare.com/docs/resources/categories
// Foursquare category ids:
// Bar: 4bf58dd8d48988d116941735
// Whisky bar: 4bf58dd8d48988d122941735
export const fetchVenues = ({ latitude, longitude }) => {
  const params = {
    client_id: FOURSQUARE_CLIENT_ID,
    client_secret: FOURSQUARE_CLIENT_SECRET,
    intent: 'browse',
    limit: 10,
    categoryId: '4bf58dd8d48988d116941735',
    radius: 1000,
    v: '20180323',
    ll: `${latitude},${longitude}`
github DefinitelyTyped / DefinitelyTyped / types / mapbox__mapbox-sdk / mapbox__mapbox-sdk-tests.ts View on Github external
import MapiClient, { SdkConfig } from '@mapbox/mapbox-sdk/lib/classes/mapi-client';
import { MapiRequest } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
import { MapiResponse } from '@mapbox/mapbox-sdk/lib/classes/mapi-response';
import Directions, { DirectionsService, DirectionsResponse } from '@mapbox/mapbox-sdk/services/directions';
import Styles, { StylesService } from '@mapbox/mapbox-sdk/services/styles';
import StaticMap, { StaticMapService } from '@mapbox/mapbox-sdk/services/static';
import { LineString } from 'geojson';

const config: SdkConfig = {
    accessToken: 'access-token',
};
const client = new MapiClient(config);

const directionsService: DirectionsService = Directions(client);

const mapiRequest: MapiRequest = directionsService.getDirections({
    profile: 'walking',
    waypoints: [
        {
            coordinates: [1, 3],
        },
        {
            coordinates: [2, 4],
        },
    ],
});

mapiRequest.send().then((response: MapiResponse) => {
    const body = response.body as DirectionsResponse;
    const route = body.routes;
github kdwink / supercharge.info / src / main / primary_entry / script / page / map / route / RoutingAction.js View on Github external
constructor(mapApi) {
        this.mapApi = mapApi;
        this.directionsClient = mbxDirections({accessToken: MapBox.accessToken});

        EventBus.addListener(RouteEvents.input_model_changed, this.handleInputModelChange, this);
        EventBus.addListener(RouteEvents.add_waypoint, this.handleAddWaypointEvent, this);
        EventBus.addListener(RouteEvents.route_selected_for_load, this.handleRouteSelectedForLoad, this);
    }