D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
d3noob
Full window
Github gist
Multiple tile layers in leaflet.js
An example of using leaflet.js with multiple tile layers.
<!DOCTYPE html> <html> <head> <title>Simple Leaflet Map</title> <meta charset="utf-8" /> <link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet-0.7/leaflet.css" /> </head> <body> <div id="map" style="width: 600px; height: 400px"></div> <script src="https://cdn.leafletjs.com/leaflet-0.7/leaflet.js"> </script> <script> var osmLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>', thunLink = '<a href="https://thunderforest.com/">Thunderforest</a>'; var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib = '© ' + osmLink + ' Contributors', landUrl = 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png', thunAttrib = '© '+osmLink+' Contributors & '+thunLink; var osmMap = L.tileLayer(osmUrl, {attribution: osmAttrib}), landMap = L.tileLayer(landUrl, {attribution: thunAttrib}); var map = L.map('map', { layers: [osmMap] // only add one! }) .setView([-41.2858, 174.78682], 14); var baseLayers = { "OSM Mapnik": osmMap, "Landscape": landMap }; L.control.layers(baseLayers).addTo(map); </script> </body> </html>