Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Per Liedman
@perliedman
@ryan-morris interesting, definitely think this is a use case... when you say a "shape" that is drawn on the map, what does that typically mean? You say it's not a set of waypoints, but what is it?
Just guessing from your description, but it sounds like what you are describing might be a bit too far outside LRM's current scope, so it might be hard to force LRM to do this. But I certainly don't have the whole picture, so I might of course be wrong.
Maybe you can re-use some of the components in LRM for the parts that are similar.
Ryan Morris
@ryan-morris
@perliedman The shape represents the path you want a vehicle to take. Like with OSRM you can specify waypoints, A->B , go by C, but the shape is the full path with all points on the line. With google maps, you max a 10 waypoints if you try to utilize the directions api, osrm also has a limit on the number of waypoints, and it results in giving directions every few meters to the next point (arrived at some random coordinate type directions are produced_
Ryan Morris
@ryan-morris
even if the user relies on the suggested path provided from one of the directions api and makes no changes to the path they want to go. (Take x street instead of y street even though theres no stops on the street) , the next time they load for edit, if we use just the stops as waypoints, they might be given an entirely new "shape", and would have to reapply their changes every time
Mauro Spivak
@mspivak
Hi there! Anyone knows how to get the changed (or added, or deleted) waypoints after a change? I'm using waypointschanged and all of use I can see is to use event.waypoints but I'd have to compare that to a copy and it seems too much work.
I mean, when the event is fired after a drag and drop, how do I get the changed waypoint alone?
+/-*
@RomanSurface_twitter
Map_bug.png
hey @perliedman since today my map is showing strange gray lines instead of routing lines. It happens just on load, once i pan or zoom in i get back the correct route and the grey lines disappear. Did i brake something?
+/-*
@RomanSurface_twitter
forgot to say : i am using mapbox routing engine
+/-*
@RomanSurface_twitter
@perliedman : just found out the reason why. I was using Mapbox router and on the first call to their rest apis your library (that i love) is passing overview=false as request param while seems like it is needed overview=full. I hardcoded this in the library and everything works fine now. Let me know if this is the right patch or we shoul do something different. Thanks a lot.
Per Liedman
@perliedman
@RomanSurface_twitter overview=false should give a lower resolution route, IIRC, so if that gives the result above, it sounds like they have changed their API...
the overview=full give a full resolution version, but the reason for not always using it is that it requires more bandwidth/resources and might be slow when changing the route, for example while dragging.
I remember the OSRM devs putting a lot of emphasis on implementing this feature to LRM, although I have not benchmarked myself with/without it.
fas3r
@fas3r
Hello @perliedman , thanks for this great plugin.
Per Liedman
@perliedman
@fas3r :+1: Thanks!
Adrian Laurenzi
@alaurenz

@RomanSurface_twitter Hi Roman, so I had the same issue and I'm fairly certain its due to a recent change on the Mapbox side. Im finding that I only see this behavior when using the walking mode, when I change to driving or bicycling it seems to work fine. And I actually sent them a support ticket about the issue which Ive copied below:

Adrian (May 13, 5:46 AM PDT):

The Mapbox Directions API for walking mode seems to be returning invalid responses for the encoded polyline (geometry) information.

For example, this query:

https://api.mapbox.com/directions/v5/mapbox/walking/-79.89673018455507,43.27421360443174;-79.89669799804689,43.27584617879126;-79.89787817001344,43.27435421064566?overview=false&alternatives=true&steps=true&access_token=pk.eyJ1IjoicGFyYWRveGljIiwiYSI6ImxIRjFDR2cifQ.hmVfSxcYVd7xUf--S1WGlQ

Produces this field in the output (the first geometry field):
"geometry": "s~fpqAbgokwCu@zAkAdEGdFFzJNzA",

"s~fpqAbgokwCu@zAkAdEGdFFzJNzA" appears to be an invalid encoded polyline as it seems to decode to a point at the north pole (verified using: https://developers.google.com/maps/documentation/utilities/polylineutility)

If you run the Directions query instead with the cycling mode, it seems to produce correct polyline output:

https://api.mapbox.com/directions/v5/mapbox/cycling/-79.89673018455507,43.27421360443174;-79.89669799804689,43.27584617879126;-79.89787817001344,43.27435421064566?overview=false&alternatives=true&steps=true&access_token=pk.eyJ1IjoicGFyYWRveGljIiwiYSI6ImxIRjFDR2cifQ.hmVfSxcYVd7xUf--S1WGlQ


Mapbox Support Response:

Hello,
The encoding is correct but the resulting output is in reverse order. You will need to decode the polyline with something like https://github.com/mapbox/polyline and then reverse the order of the output like:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [ [ -79.896706,43.274234 ],
[ -79.896752,43.274261 ],
[ -79.896851,43.274299 ],
[ -79.896966,43.274303 ],
[ -79.897156,43.274299 ],
[ -79.897202 ,43.274291] ]
}
}
]
}

​Does this help or answer your questions?
Rafa Gutierrez
Mapbox Support

+/-*
@RomanSurface_twitter
@perliedman thanks a lot for explaining; now it makes sense to me. I dont know why but with overview set to full the problem disappear and i get a well formed response. Probably they are changing their API yes.
Joern
@vincentvermeer_twitter
Hi, i have read all the documentations, but i haven't found how i could simply add an waypoint. I have a rout wit one start and one endpoint. Waht i want is adding a third waypoint in the middle of the route. WIth "spliceWaypoints" i must delete one waypoint, but i only want to add one.
Per Liedman
@perliedman
@vincentvermeer_twitter spliceWaypoints works exactly like JavaScript's Array.splice, and you are free to set the number of items to delete to 0 if you just want to add.
@vincentvermeer_twitter see for example https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice, the first example performs an add without removing.
Joern
@vincentvermeer_twitter
@perliedman ah okay, thanks for the example - and thanks for the plugin
Kradenko
@Kradenko
Hi @perliedman Strange thing, I have just come across a problem with changing the order of the waypoints in the waypoint list. master_plan is of type L.Routing.Plan in these examples. Also, there is 20 waypoints, and I am swopping items in the middle of the pack. I get undefined when calling master_plan.spliceWaypoints(oldIndex, 1). I am trying to do this master_plan.spliceWaypoints((parseInt(newIndex)), 0, master_plan.spliceWaypoints(oldIndex, 1)[0]); which returns undefined. Tested it with normal Javascript and it seems to work fine. Any idea why?
Kradenko
@Kradenko
I have a work around, use the getWaypoints method, do the move, then just use the setWaypoints method to update the Plan. Still not sure if I am doing something wrong with the spliceWaypoints function.
Mauro Spivak
@mspivak
Hi there! Anyone used Leaflet, LRM and Graphhopper altogether on Angular 6? I'm running into a few issues.
+/-*
@RomanSurface_twitter
hey @perliedman i m running mapbox router and when i set the profile to walking your js brakes and not displaying the route on the map. If i switch to profile driving or cycling everything works fine. This is the cycling req: https://api.mapbox.com/directions/v5/mapbox/cycling/12.4786,41.8925;12.4900422,41.8902102;12.4725952,41.9041517;12.46664,41.89773;12.4795065,41.8763068;12.4883736,41.9048085;12.4900422,41.8902102;12.4663759,41.8886937;12.4539367,41.9021667;12.453389,41.902916;12.4708431,41.8899547;12.46200799,41.90370121;12.47324002,41.88859556;12.466459,41.901763;12.464748,41.9024051;12.4768,41.8986;12.472401,41.899649;12.47316,41.89787;12.475983,41.911564;12.47633718,41.91181785;12.4825272,41.9057538;12.49518,41.89073?overview=full&alternatives=true&steps=true&access_token=pk.eyJ1IjoicGlldHJvdmlyZ2kiLCJhIjoiODZoMXhaNCJ9.5PAgbaNgNpmy1DgHHifaCQ and this is the walking req :https://api.mapbox.com/directions/v5/mapbox/walking/12.4786,41.8925;12.4900422,41.8902102;12.4725952,41.9041517;12.46664,41.89773;12.4795065,41.8763068;12.4883736,41.9048085;12.4900422,41.8902102;12.4663759,41.8886937;12.4539367,41.9021667;12.453389,41.902916;12.4708431,41.8899547;12.46200799,41.90370121;12.47324002,41.88859556;12.466459,41.901763;12.464748,41.9024051;12.4768,41.8986;12.472401,41.899649;12.47316,41.89787;12.475983,41.911564;12.47633718,41.91181785;12.4825272,41.9057538;12.49518,41.89073?overview=full&alternatives=true&steps=true&access_token=pk.eyJ1IjoicGlldHJvdmlyZ2kiLCJhIjoiODZoMXhaNCJ9.5PAgbaNgNpmy1DgHHifaCQ They both return 200 with a valid data structure. Your library logs this error for the walking profile : message: "TypeError: Cannot read property 'name' of undefined". Thanks a lot in advance!
Éloi Rivard
@azmeuk
Hello
I am struggling with displaying multiple routes on a map. At the moment, if 2 routes goes by the same street, only the top one is visible. I would love to be able to implement one of those solutions:
  • Display the two routes side by side. This would be absolutely epic.
  • Make a route go on top when it is clicked.
    Someone has a clue?
akmalnodirov
@akmalnodirov
Hello
I have a question, about service like travelling salesman,
In leaflet routing machine deafult built in servive is OSRM. and OSRM has a travelling salesman service
How can i use this service in leaflet routing machine ?
im not good at js
Przemysław Lazarek
@Daredzik
Hello ;) If somone need HERE maps plugin to LRM go check it => https://www.npmjs.com/package/leaflet-routing-machine-here
WillemvdW
@WillemvdW

@perliedman Hey man, thanks for getting back to me!! I appreciate your feedback. I made a start on a POC today and I'm feeling a little more confident about building it. But yes, I've already come across some weird stuff, like if a GPS coordinate is on the other side of the road from the way you are going it does really strange stuff! Anyway, I'll have a crack at getting something going over the next few weeks and post the results somewhere.

@hutch120 I am following up on your post "I've got a client who needs turn-by-turn audible instructions and next turn visual instruction highlighted (based on current GPS coordinates). Has anyone done that? I was thinking of using the "Web Speech API"... We have done this with the web speech api, but need to present the next turn visually on the screen. Did you implement this functionality?

Ioannis Gkinis
@giannisginis
Hi everyone, i have a question....Is it possible to use my custom network and my own custom cost with leaflet-routing machine?
Per Liedman
@perliedman
@giannisginis as long as you use a routing engine supported by LRM, then yes.
Ioannis Gkinis
@giannisginis
@perliedman thanks for the quick response...are there any instructions for how i will manage to do it?
Per Liedman
@perliedman
@giannisginis it depends... I mean, in what format is your custom network/custom cost?
@giannisginis and of what size...
Ioannis Gkinis
@giannisginis
@perliedman my network is in vector format (shapefile)...the cost i want to use is the condition of each pavement (i have this information at attribute table)...of course i can convert them at geojson etc if needed...
@perliedman the size is not too big...
Per Liedman
@perliedman
@giannisginis alright. I think there's some way to import shape into osrm, or at least there was at some point, but I imagine it could be complicated.
for geojson of reasonable size, you might be interested in geojson-path-finder, which I have written: https://github.com/perliedman/geojson-path-finder/
there's no official code to use it with LRM, but if you look at the demo, you can see I use LRM as the frontend there, there isn't much code.
in particular, the "router" code that is used to glue LRM with geojson-path-finder is here: https://github.com/perliedman/geojson-path-finder/blob/gh-pages/router.js
Ioannis Gkinis
@giannisginis
@perliedman thank you so much! i will have a look at these references!