leaflet-routing-machine
leaflet-routing-machine copied to clipboard
Can't use Waypoints instead of latLng
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",
Forget about that. I just figured it out. The right way to create entities is using the lowercase method:
L.Routing.waypoint(...)