JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css">
<script src="https://rawgit.com/perliedman/leaflet-routing-machine/master/dist/leaflet-routing-machine.min.js"></script>
<link rel="stylesheet" href="https://rawgit.com/perliedman/leaflet-routing-machine/master/dist/leaflet-routing-machine.css">
<script src="https://rawgit.com/jacobtoye/Leaflet.iconlabel/master/dist/leaflet.iconlabel.js"></script>
<link rel="stylesheet" href="https://rawgit.com/jacobtoye/Leaflet.iconlabel/master/dist/leaflet.iconlabel.css">
<button class="route-btn" onclick="ResetRoute()">Reset Button</button>
<div id="map" style="height: 500px"></div>
JavaScript
//Leaflet Routing Machine reset test
var map = new L.Map('map').setView([34.07, -118.2], 11);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var route = L.Routing.control({
plan: L.Routing.plan([
L.latLng(34.06, -118.25),
L.latLng(34.02, -118.5)
], {
createMarker: function(i, wp) {
return L.marker(wp.latLng, {
draggable: true,
icon: new L.Icon.Label.Default({ labelText: String.fromCharCode(65 + i) })
});
},
routeWhileDragging: true
}),
fitSelectedRoutes: false,
routeWhileDragging: true,
routeDragTimeout: 250,
showAlternatives: true
}).addTo(map);
var ResetRoute = function () {
alert('aaaaaa');
route.setWaypoints([L.latLng(map.getCenter()), L.latLng(map.getCenter())]);
}