GithubHelp home page GithubHelp logo

mapbox / mapbox-gl-directions Goto Github PK

View Code? Open in Web Editor NEW
231.0 111.0 124.0 1.82 MB

Directions plugin for mapbox-gl-js using Mapbox Directions API.

Home Page: https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/

License: ISC License

CSS 26.54% HTML 4.29% JavaScript 69.17%
mapbox-gl-js mapbox osrm javascript

mapbox-gl-directions's Introduction

Mapbox GL Directions

A full featured directions plugin for Mapbox GL JS using the Mapbox Directions API. Quickly add UI to display driving, cycling, or walking directions on the map. The Mapbox 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 Mapbox Android Services, MapboxDirections.swift, and MapboxNavigation.swift.

Usage

var mapboxgl = require('mapbox-gl');
var MapboxDirections = require('@mapbox/mapbox-gl-directions');

var directions = new MapboxDirections({
  accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
  unit: 'metric',
  profile: 'mapbox/cycling'
});

var map = new mapboxgl.Map({
  container: 'map'
});

map.addControl(directions, 'top-left');

Live example: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/

Deeper dive

See API.md for complete reference.

Contributing

See CONTRIBUTING.md.

mapbox-gl-directions's People

Contributors

1ec5 avatar adrianababakanian avatar anandthakker avatar avpeery avatar bbantsadze avatar chriswhong avatar clairethompson avatar freenerd avatar geografa avatar ginnyfahs avatar hassan950 avatar jonkoops avatar kind3r avatar malwoodsantoro avatar mapsam avatar michaelskahn avatar mollymerp avatar pankajparkar avatar stepankuzmin avatar thibaudlopez avatar tmcw avatar tristen avatar underoot avatar waldyrious avatar willwhite avatar yuchuntsao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapbox-gl-directions's Issues

Better request management on endpoint dragging

@tristen Currently the endpoint dragging is very laggy, because it sends too many requests. We can drastically improve the experience by doing two things:

  1. Throttle or debounce the requests. They shouldn't fire more often than 200ms, maybe more.
  2. Cancel outdated requests โ€” when you move the mouse, only the latest position is relevant but requests for all previous points during the move still hang until completed. See GL JS for an example of request canceling (we do this for tiles).

image

Documentation in the README

  • Description
    • Overview
    • Version number
    • Testing badges
    • Link to live site (if applicable)
  • Usage
    • How to use it with code samples
    • Links to documentation (if applicable)
  • Running locally
    • How to run it locally
    • Include dependencies
  • Testing
    • How to test it locally

Better feature design

  • Pseudo class styling. Unlocked by mapbox/mapbox-gl-js#200?
  • Features should float more on top of the map
  • Better/Clearer marker origin/destination styling
  • Labels on Alternate and Selected route indicating Time/Distance based on mode of commute.
  • Tooltips on waypoints to instruct dragging

Tests

There are no tests for this library. Please add tests before adding code.

Plugin not taking the clicked position

When clicked on the map the marker is not appearing at the clicked place but displaying in another place.

To recreate the same:

  • Zoom in to India.
  • Click on one of the major roads near Pune.

What I expect :- Marker/circle to appear on the clicked place.

What I see :- Marker appearing away from the clicked place and geocoding to Maharashtra.

ani1

Allow interaction to be toggled on or off

When you click on the map with mapbox-gl-directions initialized it will always listen for click events and re-plot origin/destination points. We should expose a disable method to toggle this from happening.

Better instruction item format/details

More details could be included here. i.e

+------------------------------------------+
|                                          |
| +---+  Distance                          |
| |   |  STREET NAME                 Time  |
| +---+  Instruction                       |
|                                          |
+------------------------------------------+

Handle errors in the UI

Something like this should be communicated to the user:

screen shot 2015-12-01 at 2 08 35 pm

Also pass as an event to directions.

stop using assets from S3

This file is no longer going to be getting updates. This should be switched to use a tagged release from api.mapbox.com or local copy with the desired version.

Infer container if no element is passed

Also, In addition to that change, a passed container option should look like this:

Current:

new mapboxgl.Directions(document.getElementById('map'));

Proposed:

new mapboxgl.Directions({
  container: 'map'
});

This follows the same convention as mapbox-gl-js

v5: use legs

instead of the current hacks around waypoints we should use the routes.legs that Directions V5 supports

Directions treats way name changes as intersections

This is very likely a ticket for the directions API or data team, but if those are internal this may be the best bet; please direct me if this should be posted elsewhere

screenshot 2015-12-11 12 12 03

In certain sections of US Interstate highway navigation, the directions plugin is offering guidance at every exit and subtle change of road name. I'm not familiar with how the underlying data came to be structured this way, but the navigation algorithm should be able to recognize consistency between segments of the same limited-access highway.

Add a loading state

Clicking on a point on the map coordinates a request to the geocoder before it's drawn. On slower networks this takes a beat so we should communicate something is happening.

screen shot 2015-12-02 at 11 31 18 am

Pass options

On initialization and action fired.

  • accessToken: TOKEN
  • unit: metric/imperial for distance calculation
  • proximity: [lng,lat] to bias results

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.