A full featured directions plugin for TrackAsia GL JS using the TrackAsia Directions API. Quickly add UI to display driving, cycling, or walking directions on the map. The TrackAsia Directions API is powered by the OSRM routing engine and open data from the OpenStreetMap project.
For directions functionality in native mobile and desktop applications, see TrackAsia Android Services, TrackAsiaDirections.swift, TrackAsiaNavigation IOS, TrackAsiaNavigation Android
npm install trackasiagl --save # if not already installed
npm install trackasia-gl-directions --save
- CommonJS
var trackasiagl = require('trackasia-gl');
var TrackAsiaDirections = require('trackasia-gl-directions');
var directions = new TrackAsiaDirections({
unit: 'metric',
profile: 'drive'
});
var map = new trackasiagl.Map({
container: 'map',
style: 'https://tiles.track-asia.com/tiles/v1/style-streets.json?key=public'
});
map.addControl(directions, 'top-left');
- ESM
import trackasiagl from 'trackasia-gl';
import TrackAsiaDirections from 'trackasia-gl-directions/dist/trackasia-gl-directions';
import 'trackasia-gl/dist/trackasia-gl.css';
import 'trackasia-gl-directions/dist/trackasia-gl-directions.css';
var directions = new TrackAsiaDirections({
unit: 'metric',
profile: 'drive'
});
var map = new trackasiagl.Map({
container: 'map',
style: 'https://tiles.track-asia.com/tiles/v1/style-streets.json?key=public'
});
map.addControl(directions, 'top-left');
Live example: https://docs.track-asia.com/example/direction-between-two-points/
-
B1: Build the project and skip warning redux in production:
npm run prepublish
-
B2: Pusblish to npm. Note: check version again. Example current version: 4.1.9 after publishing it is 4.2.0
npm run publish
See API.md for complete reference.
See CONTRIBUTING.md.