Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 1.57 KB

webmap-tiles.md

File metadata and controls

25 lines (19 loc) · 1.57 KB

Map Tiles

See the Leaflet recommended reading below for context around what map tiles literally are (at least in a raster web context).

To use some of Mapbox's pre-made styles, you'll have to have a Mapbox access token (which you can get by simply signing up for a free account). Then you'll want to create a Leaflet tile layer using something like this:

const mapboxAccount = 'mapbox';
const mapboxStyle = 'light-v10';
const mapboxToken = '...'
L.tileLayer(`https://api.mapbox.com/styles/v1/${mapboxAccount}/${mapboxStyle}/tiles/256/{z}/{x}/{y}@2x?access_token=${mapboxToken}`, {
    maxZoom: 19,
    attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
}).addTo(schoolMap);

Any time you use tiles directly from or based on some ready-made source, be sure to use an appropriate attribution. The attribution used above was taken from Mapbox's documentation.

Recommended reading

Other resources