- $(".directions_form .reverse_directions").on("click", function() {
- var from = endpoints[0].latlng,
- to = endpoints[1].latlng;
+ $(".directions_form .reverse_directions").on("click", function () {
+ var coordFrom = endpoints[0].latlng,
+ coordTo = endpoints[1].latlng,
+ routeFrom = "",
+ routeTo = "";
+ if (coordFrom) {
+ routeFrom = coordFrom.lat + "," + coordFrom.lng;
+ }
+ if (coordTo) {
+ routeTo = coordTo.lat + "," + coordTo.lng;
+ }