Skip to main content

Directions

Directions functionality allows you to find an optimal route between multiple points (up to ten) and draw it on the map.

The plugin uses the Routing API. To work with the API of the service, you need to get an access key: see the Creating access keys instruction.

Next, you need to include the Directions plugin in your project. To do this, add the following line after the main MapGL script:

<script src="https://unpkg.com/@2gis/mapgl-directions@^2/dist/directions.js"></script>

Or you can install the needed package using npm:

npm install @2gis/mapgl-directions

This plugin calls Directions API under the hood to find a route. If you want, you can use your Directions API key to call the API directly instead of (or in addition to) using the plugin.

To start using the plugin, check the following resources: