I want a route to bindpop's location through a button in the bindpopup . Everything works fine, but when I press the button It doesn't work, can someone help me?
//function route popup
function routeFunction(e){
let control = L.Routing.control({
waypoints: [
L.latLng(latitude,longitude)
]})
let buttonRouting = document.getElementById("idRoute")
L.DomEvent.on(buttonRouting, 'click', function() {
control.spliceWaypoints(control.getWaypoints().length - 1, 1, e.latlng);
});
}
for (let i = 0; i < arrayDistrict.length; i++) {
baklava = L.geoJSON(data, {
onEachFeature: (features, layer) => {
let naam = features.properties.NAAM;
let postcode = features.properties.POSTCODE;
let district = features.properties.DISTRICT;
let omschrijving = features.properties.OMSCHRIJVING;
layer.setStyle(myStyleStadsdeel);
layer.bindPopup(`<div class = 'popup'>${naam}</div> <br> <div class = 'popup'>${postcode}</div>
<div class = 'popup'>${district}</div> <br> <div class = 'popup'>${omschrijving}</div><br>
<button id= "idRoute" onclick="routeFunction()"> Klik voor route </button>`)
}
I get this message when i press the button.
"leaflet.js:106 Uncaught TypeError: Cannot read property 'latlng' of undefined
at routeFunction (leaflet.js:106)
at HTMLButtonElement.onclick ((index):1)"
I want a route to bindpop's location through a button in the bindpopup . Everything works fine, but when I press the button It doesn't work, can someone help me?
//function route popup function routeFunction(e){ let control = L.Routing.control({ waypoints: [ L.latLng(latitude,longitude) ]}) let buttonRouting = document.getElementById("idRoute") L.DomEvent.on(buttonRouting, 'click', function() { control.spliceWaypoints(control.getWaypoints().length - 1, 1, e.latlng); }); }