Marketplace
>
getDirectionsWithMapbox
mapbox

getDirectionsWithMapbox

v
0.0.1
Latest Version
Likes
0
Installations
0
1
Views
0
12

Overview

Get Directions for optimal driving, walking and cycling routes using the Mapbox API.

Usage

### How this function works You can use this function to get Directions for optimal driving, walking and cycling routes using the [Mapbox API](https://www.mapbox.com/). ### Prerequisites - You must have previous knowledge of **MapBox Directions**. - You must have previous knowledge of **Cloud Firestore**. ### Function details To install this function, add the required information to the form with the following parameters: - **Document Path**: The document path that you'd like this function to listen to. A placeholder should be used for the document ID (e.g., `/collection/{docId}`). - **MAPBOX_TOKEN**: The Mapbox API Key. - **DIRECTIONS_FIELD_NAME**: The name of the document field where the directions will be stored. - **WAYPOINTS_FIELD_NAME**: The name of the document field where the waypoints will be get. - **PROFILE**: The type of [Routing Profile](https://docs.mapbox.com/api/navigation/directions/#routing-profiles) can be driving, driving-traffic, walking and cycling. - **GEOMETRIES**: The format of the returned geometry. Allowed values are: geojson (as [LineString](https://tools.ietf.org/html/rfc7946#appendix-A.2)), [polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) (a polyline with a precision of five decimal places), [polyline6](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) (a polyline with a precision of six decimal places). - **LANGUAGE**: Language of returned turn-by-turn text instructions. See [supported languages](https://docs.mapbox.com/api/navigation/directions/#instructions-languages). ### Using this function Once the function is installed, you can start adding documents to the collection that would trigger this function. The document must have either a `waypoints` that must be an ordered array of [DirectionsWaypoint](https://github.com/mapbox/mapbox-sdk-js/blob/main/docs/services.md#directionswaypoint) objects, between 2 and 25 (inclusive). ```json { "waypoints": [ { "coordinates": [13.4301, 52.5109], "approach": "unrestricted" }, { "coordinates": [13.4265, 52.508] }, { "coordinates": [13.4194, 52.5072], "bearing": [100, 60] } ] } ``` > A full response object can be found in [Response: Retrieve directions](https://docs.mapbox.com/api/navigation/directions/#response-retrieve-directions) section in Mapbox API docs. ### Usage examples Here are some examples of documents to trigger this function. #### Example 1: To get directions for moving from one point to another ```javascript { "waypoints": [ { "coordinates": [2, 3], }, { "coordinates": [1, 1] }, } ``` ### Resources - [Mapbox Directions API page](https://docs.mapbox.com/api/navigation/directions/)
Cost
FREE
Cost
Version
0.0.1
Language
JAVASCRIPT
Created At
Updated At
Workspace
mapbox
Tags
© 2023 Function Store