1

I'm working on a project and I need to display points of interest that are saved in a database.

For the itinerary, I used leaflet routing machine and nominatim.

Now I need to display those points of interest that are 5km around the route.

I found in this link https://www.liedman.net/leaflet-routing-machine/api/#iroute the property "coordinates". It returns an array of all the waypoints used to display the itinerary.

How can I use this function to make a call on my database each kilometer to get my informations ?

I hope I was clear and thank you !

Zhe Hu
  • 3,777
  • 4
  • 32
  • 45
Massyl
  • 19
  • 2
  • I didn't understand the question at first and commented on it asking why you needed waipoints when you already have them. – Gurgolo Aug 08 '22 at 13:38

2 Answers2

0

I worked on a similar problem and in my case I queried the routing server directly and got the coordinates of each step between the waypoints.

Gurgolo
  • 304
  • 3
  • 19
  • Okay, and how did you do that please ? Is there any Library where I can find something ? – Massyl Aug 11 '22 at 13:18
  • 1
    I used [Porject OSRM](http://project-osrm.org/) and look at the [documentation](http://project-osrm.org/docs/v5.24.0/api/#). I suggest you use a docker. It is all explained. – Gurgolo Aug 12 '22 at 09:13
0

I found it ! I used this :

    L.Routing.control({
        waypoints: [(my waypoints)],
       (my options)
    }]}
}).on('routesfound', function(e){
    console.log(e);}

The console.log(e) show all the coordinates we want to work on. And there is a yt video explaining that : https://www.youtube.com/watch?v=6mAdRdwZihc

For those who have the same problem

Massyl
  • 19
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 28 '22 at 18:53