leaflet-routing-machine icon indicating copy to clipboard operation
leaflet-routing-machine copied to clipboard

Can't use Waypoints instead of latLng

Open mspivak opened this issue 8 years ago • 1 comments

It works fine if I use an array of L.latLng objects. However if I want to use Wayopoints (in order to send the stop name), I get:

TypeError: this.callInitHooks is not a function at Object.NewClass [as Waypoint]

Here's my code:

let stops = [];
self._.each(self.route.stops, function(stop) {
  stops.push(
    L.Routing.Waypoint(
      L.latLng([parseFloat(stop.lat), parseFloat(stop.lon)]),
      stop.name
    )
  )
})

let control = L.Routing.control({
  waypoints: stops,
  [ ... ]

Relevant part of my bower.json:

"leaflet": "^1.3.4",
"leaflet-routing-machine": "^3.2.12",
"lrm-graphhopper": "^1.2.0",

mspivak avatar Oct 02 '18 12:10 mspivak

Forget about that. I just figured it out. The right way to create entities is using the lowercase method:

L.Routing.waypoint(...)

mspivak avatar Oct 02 '18 18:10 mspivak