Einfacher Rotenplaner 2
Durch Verschieben 2 Marker werden beim jeden verschieben der Marker die Routen neu berechnet
Kommentar abgeben zu diesen Beitrag/Code ?Dann hier klicken
Der hier verwendete Code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Leaflet Routing Machine Example</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
<style>
#map{
height:500px;
}
</style>
</head>
<body>
<div id="map" class="map">
<style>
#map{
height: 500px;
}
.map{
height: 500px;
}
</style>
</div>
<script>
/*var mymap = L.map('map').setView([10.0377,105.7813], 13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: 'pk.eyJ1IjoidGhhaXBodWMiLCJhIjoiY2ptcnJ4enp0MXh5cTNrazQxeDZiM2JidyJ9.BTPswkG7tgmqf9Gpx_pLnQ'
}).addTo(mymap);
L.Routing.control({
waypoints: [
L.latLng(10.050093, 105.771378),
L.latLng(10.05048, 105.773025)
],
routeWhileDragging: true
}).addTo(mymap);*/
/*var marker = L.marker([10.0377,105.7813]).addTo(mymap);
marker.bindPopup("<b>Hello world!</b><br>I am a popup.").openPopup();*/
var map = L.map('map').setView([53.900,8.900], 14);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}{r}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.Routing.control({
waypoints: [
L.latLng(53.900, 8.900),
L.latLng(53.800, 8.800)
],
routeWhileDragging: true
}).addTo(map);
</script>
</body>
</html>