Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Per Liedman
@perliedman
A common way to solve this is to pass a callback to RunRoute and then call the callback inside the routesfound handler. Or you can use a Promise to achieve similar things, depends on you environment and what code style you prefer.
If you haven't already, you should familiarize yourself with callbacks and other common tools for handling asynchronous stuff in JavaScript, you are going to need it!
ThomsoG1-JEG
@ThomsoG1-JEG
@perliedman Yeah its one thing that I have been trying to get my head round, but its a bit of a learning curve... At least I know I'm on the right track with it. I tried implementing promises but couldnt quite dial it in. I'll keep digging. Cheers!
shahzodjonweb
@shahzodjonweb
Hi I am new leaflet. I have Firstly installed leaflet map and then included Leaflet Routing Machine Scripts and css files. There error in console: Cannot read property 'control' of undefined. Can you help me, please.
<!DOCTYPE html>
<html lang="en">

<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />

<style>

#mapid { height:600px;width:1300px; }

</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
</head>

<body>

<div id="mapid"></div>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>

<script>


var mymap = L.map('mapid').setView([39.74083900, 64.18180370], 13);


L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(mymap);

var control = L.Routing.control({
        waypoints: [
            L.latLng(57.74, 11.94),
            L.latLng(57.6792, 11.949)
        ],
        routeWhileDragging: true,
        geocoder: L.Control.Geocoder.nominatim()
    });

</script>


</body>

</html>
shahzodjonweb
@shahzodjonweb
That's my all code
WillemvdW
@WillemvdW
@BelisleC did you get an answer to your query. We had a suimilar requirement and ended up editing the route file. We used leaflet to draw a line that would be the route, and then we manually edited the waypoints.
HunzlaSheikh
@HunzlaSheikh

I have a textbox. I want to implement leaflet map search functionality on that textbox. Also when user search address, then on selecting address i want to get its coordinates (latitude, longitude).

How can i achieve this functionality? Please help.

BelisleC
@BelisleC
@WillemvdW no I did not get a response. I ended up using geoJSON pathfinder and then used turf.js to dynamically select start and finish points that landed on my network and used leaflet to draw the pathfinder coordinates as a Polyline. Worked for my purposes :) thanks for the suggestion.
Louis-Etienne Leuilliot
@Dreanad
Hello there ! :) i have a question can you help me ?
I have some lines, and the user create a route when select multiple line, how can i convert selecteds lines in one route ? i need to get this coordinate, not calculated by osrm
Louis-Etienne Leuilliot
@Dreanad
No one ? how can i set coordinate for a route ?? :(
Louis-Etienne Leuilliot
@Dreanad
Help ? :(
im still with my problem x) i have a lot of coordinate, and need to make a route with instruction
Nico Aliotta
@nicoali
hi! is it possible to use leaflet routing to show a line mapping point after point sent by a gps of a smartphone?
PeterPan73
@PeterPan73
lf.PNG
How i can add label for each input?
Artur Marchi
@marchiartur
hi guys, some tutorial for routing ?
HunzlaSheikh
@HunzlaSheikh
Need help?
I am using routing control. Problem is path not showing by default until i zoom out/in map. By zoom out/in it start to showing path. whats the problem? anyone help please?
JoaquimCardoso1993
@JoaquimCardoso1993
hi, i need help :)
Mael FOSSO
@maelfosso
Hello
Please, I need help
I have this error
Routing error:
{message: "HTTP request failed: undefined", url: "https://router.project-osrm.org/route/v1/driving/8…erview=false&alternatives=true&steps=true&hints=;", status: -1, target: XMLHttpRequest}
message: "HTTP request failed: undefined"
status: -1
target: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
url: "https://router.project-osrm.org/route/v1/driving/85.316,27.67;85.321,27.68?overview=false&alternatives=true&steps=true&hints=;"
1 reply
How to fix it please?
hgiirl
@hgiirl
Hello
Is there any one to help pls? Thanks
ZAG92
@ZAG92
i need to make route in indoor map leaflet from point A to B
how can i do this
WillemvdW
@WillemvdW
we managed that by editing the routing file directly
ZAG92
@ZAG92
more details please?
WillemvdW
@WillemvdW
When the routing engine prepares a route, it generates a json file containing the routing instructions. You can see the details here. https://www.liedman.net/leaflet-routing-machine/api/#routingoptions. We used the map, drew a line representing the route to be taken including the route through the buildings. and then we added the waypoints manually.
ZAG92
@ZAG92
we dont have maps in indoor its just an image
that contains details about places
you mean i draw line from point a and point b on that image and then aded waypoint manually
WillemvdW
@WillemvdW
We used the map as the foundation, and used the leaflet tools to draw the line along the route that we wanted the user to follow. This route went through a harbour area, and major buildings, steps etc. To use the routing engine you will have to have it map based, but you can overlay any image as a base layer of course.
ZAG92
@ZAG92
is there any example related to overlay anyimage ?
ZAG92
@ZAG92
??
ZAG92
@ZAG92
guys please help here
Mirco Luperi
@LuperiMirco_twitter

hi, I am a university student. for a project I created a small web app using leaflet and leaflet routing machine. I have a problem due to lack of experience in the sector.
I have this warning:
"You are using OSRM's demo server. Please note that it is NOT SUITABLE FOR PRODUCTION USE.
Refer to the demo server's usage policy: https://github.com/Project-OSRM/osrm-backend/wiki/Api-usage-policy

To change, set the serviceUrl option.

Please do not report issues with this server to neither Leaflet Routing Machine or OSRM - it's for
demo only, and will sometimes not be available, or work in unexpected ways.

Please set up your own OSRM server, or use a paid service provider for production."

to make the app usable, do i have to change the serviceUrl option?
how do it?

2 replies
xenPanda
@xenPanda
Hi there. I am new to leaflet, and just found the Routing Machine. Routing Machine does much of what I am looking to do, but I do not need routing via roads. I would like to route direct straight line waypoint to waypoint as would be done for aviation or nautical routes. Is this easily accomplished with the Routing Machine?
2 replies
Chris Allison
@quimarche
Is anyone here using GeoJSON Path Finder?
Specifically, I've got Leaflet Routing Machine working just fine with OSMR; plugging in a network geojson is good (I can display the network in Leaflet), but calling pathFinder.findPath() returns null.
RZsam
@RZsam
I want more than one route between two waypoints but couldn't find any way.
do you have any suggestions?
1 reply
Louis-Etienne Leuilliot
@Dreanad

Hello there ! its me again

so, i have my polyline now simplyfied and clean,

but there is some error in my itinerary,

To construct my itinerary i encode a polyline with a lot of coordinates, and for reduce them i take from the instruction only steps that have a modifier element
but sometimes it is not working like expected

https://ibb.co/D48qx4S

on the capture, you can see the purple line, its my itinerary, and the red is the generated route
how can i do that ?

( its a simple example, but i have more complexe sometimes, its really weird, i dont know how is generate the route i have sometimes my route going into an impass and come back ??? )

prohibited direction is authorized but it doesn't seem to be taken into account.

Ivan Bodnar
@Vandeko1
What does the error mean?
leaflet-routing-machine.js:15868
Routing error: {status: -1, message: "OSRM request timed out."}
    <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
    <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
    <script src="Control.Geocoder.js"></script>
    <script>
        var mymap = L.map('mapid').setView([48.89, 24.66], 14);
        L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=1234567890qwertyuiop', {
            maxZoom: 18,
            attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
                '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
                'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
            id: 'mapbox/streets-v11',
            tileSize: 512,
            zoomOffset: -1
        }).addTo(mymap);


        L.Routing.control({
            waypoints: [
                L.latLng(48.87, 24.62),
                L.latLng(48.91, 24.69)
            ],
            routeWhileDragging: true,
            geocoder: L.Control.Geocoder.nominatim()
        }).addTo(mymap);
    </script>
1 reply
Sami Greenbury
@Patabugen
I want to use Leaflet Routing Machine to draw a route - but to draw it slowly (so you can see the drive move across the country). Is there any built in magic that might make that easier for me?
sngrl
@sngrl
Does anyone know analogs in PHP for translating route hints into a text description?