Skip to content

Instantly share code, notes, and snippets.

@andion
Last active August 17, 2020 18:04
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 andion/f934d00a0944c490e439a66ba6f7f1a7 to your computer and use it in GitHub Desktop.
Save andion/f934d00a0944c490e439a66ba6f7f1a7 to your computer and use it in GitHub Desktop.
// Requires a div with id="map" on a html file with leaflet's css and js.
const towerLocation = [43.385807,-8.406524];
const mymap = L.map('map').setView(towerLocation, 16);
// GET ONE in https://docs.mapbox.com/help/how-mapbox-works/access-tokens;
const ACCESS_TOKEN = "--YOUR--ACCESS--TOKEN--";
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=' + ACCESS_TOKEN, {
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>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1
}).addTo(mymap);
const marker = L.marker(towerLocation).addTo(mymap);
marker.bindPopup("<b>Tower of Hercules</b><br/>UNESCO World Heritage site");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment