8

Here's the sample of application that draw road path based on two markers enter image description here

Sorry I cannot search the tutorial to create this one because I cannot determine the right keyword.

All i want is to place two markers, then the road path will be created between those markers. It will adjust as one marker is moved.

Please provide insights on how this can be achieved. A sample code is much appreciated. Thank you in advance.

Mellorine
  • 265
  • 1
  • 5
  • 13
  • 4
    You are probably looking for Leaflet [**Routing** plugins](http://leafletjs.com/plugins.html#routing)? – ghybs Mar 14 '16 at 16:42
  • 2
    Do you mean that the path should be recalculated while dragging? See the routeWhileDragging attribute in the LRM plugin: http://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/ – Karussell Mar 14 '16 at 21:30
  • Yes sirs, i just want to draw road path in real-time that is always in road, just like in other website that offers this feature – Mellorine Mar 21 '16 at 11:57

1 Answers1

8

This is OSRM, the Open Source Routing Machine. Here is a demo: http://map.project-osrm.org/

You can actually use it through HTTP request in any language you want: Python, javascript, java, C, ... Check the doc!

Patrick
  • 81
  • 1
  • 4
  • Hi, I see they have a "foot" option but that is moot. It is the same route as a car or bike would take mostly. Now when you set the option to have map > hike, you will see what the actual "foot" path would be. Do you know of any possibility to actually use the "hike" paths as route? I can also not find information on the pricing of this service. Is this free? Thank you! –  Apr 13 '22 at 10:59
  • Please provide code examples. – chovy Apr 16 '22 at 02:42