Skip to content

Instantly share code, notes, and snippets.

@mrbalihai
Last active November 13, 2019 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbalihai/cf1cf6642ea808d88703ddb5d7cca298 to your computer and use it in GitHub Desktop.
Save mrbalihai/cf1cf6642ea808d88703ddb5d7cca298 to your computer and use it in GitHub Desktop.
import L from 'leaflet';
import 'leaflet-routing-machine';
import data from '../../data.json';
const tileLayerUrl = `https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png`;
const attribution = `Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors,
<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>`
const map = L.map('map', {
center: [ 53.821798, -1.344509 ],
zoom: 13
});
// Add the map tiles
L.tileLayer(tileLayerUrl, {
maxZoom: 18,
attribution,
id: 'streets'
}).addTo(map);
const points = [
L.latLng(...data.location),
...data.deliveries.map(d => L.latLng(...d.location)),
L.latLng(...data.location)
];
const routing = L.Routing.control({
waypoints: points,
lineOptions: { styles: [{color: '#666'}]}
});
routing.addTo(map);
routing.hide();
// Add a marker to the map
const icon = L.icon({ iconUrl: './images/location.png', iconAnchor: [32, 16] });
L.marker([53.821798, -1.344509], { icon }).addTo(map);
import L from 'leaflet';
const tileLayerUrl = `https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png`;
const map = L.map('map').setView([53.821798, -1.344509], 13);
L.tileLayer(tileLayerUrl, {
maxZoom: 18,
attribution: `Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors,
<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>`,
id: 'streets',
}).addTo(map);
const icon = L.icon({ iconUrl: './images/location.png' });
L.marker([53.821798, -1.344509], { icon }).addTo(map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment