Draw routes in a maps

153 views
Skip to first unread message

Carlos Sánchez Pino

unread,
Apr 7, 2014, 6:28:09 AM4/7/14
to leafl...@googlegroups.com
Hello, I need your help...

I´m triying draw a  Polyline in my map and I succeeded this...

var map = L.map('map').setView([28.635308, 77.22496], 13);
var pointA = new L.LatLng(28.635308, 77.22496);
           var pointB = new L.LatLng(28.984461, 77.70641);
           var pointList = [pointA, pointB];
           
           var firstpolyline = new L.Polyline(pointList, {
                                              color: 'red',
                                              weight: 3,
                                              opacity: 0.5,
                                              smoothFactor: 1,
                                              stroke: 'false'
                                              
                                              
                                              });
           map.addLayer(firstpolyline);

This show a polyline but i need that this line follow the route of the streets. .i.e: this... http://htmlpreview.github.io/?https://github.com/JimShady/Stoller-Routing/blob/master/index.html

Can help me please?

^^


Ricardo Freitas

unread,
Apr 7, 2014, 11:11:16 AM4/7/14
to leaflet-js
Can't open your link right now but from what I learned in the past, you will need something else to pull this off - have you tried osrm with leaflet (osrm - openstreet map routing)?




--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ricardo Freitas ► Web Developer
 mail: ricardo...@fixeads.com
Message has been deleted

Akram Kashef

unread,
Apr 16, 2015, 12:56:34 PM4/16/15
to leafl...@googlegroups.com
I got the same problem ,Would you please let me know if you figured out how to solve this issue ?

Claudio Schilling

unread,
Apr 16, 2015, 2:23:51 PM4/16/15
to leafl...@googlegroups.com
You'll have to explicitly supply all the points driving the polyline path, not only the start and finish. L.polyline doesn't calculate routes, it just draws a polyline passing thru all points supplied in the pointList array.



Cláudio Schilling

Atendimento corporativo
  •  Performance Informática - Fone (51) 3231.3100

  •  Rua Barão do Amazonas, 314, Porto Alegre/RS
  •  E-mail: cla...@performanceinformatica.com
  •  Site: www.performanceinformatica.com

 


Reply all
Reply to author
Forward
0 new messages