Je suis en train de router vers un marqueur, mais je veux être en mesure de choisir un autre itinéraire et le marqueur actuel sera alors redirigé.Dépliant retirer le marqueur actuel et en ajouter un nouveau au clic
L'image 1 montre le routage actuel.
En cliquant sur le bouton 'Route to here', le marqueur actuel doit être retiré et remplacé par le nouveau marqueur.
OnClick this should remove the current marker and add a new marker
function showPosition(position)
{
//Set the map view to be the users location
//
var map = L.map('map').setView([position.coords.latitude, position.coords.longitude], 14);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
//Change the users marker to a unique red & show users location on click
//
L.marker([position.coords.latitude, position.coords.longitude], {
icon: L.AwesomeMarkers.icon({prefix: 'fa', markerColor: 'red'})
}).addTo(map).bindPopup("<b>Your location: </b>" + position.coords.latitude + "," + position.coords.longitude);
//Routing users location to the desired route
//
L.Routing.control({
waypoints: [L.latLng(users_lat_coords, users_lng_coords), L.latLng(x, y)],
lineOptions: {addWaypoints: false}
}
).addTo(map);
}