Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @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}`
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;
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);
}