Skip to content

Instantly share code, notes, and snippets.

@TheMapSmith
Forked from wboykinm/.block
Last active March 10, 2017 21:55
Show Gist options
  • Save TheMapSmith/9b9bb0244cff8967e85d1655f6041027 to your computer and use it in GitHub Desktop.
Save TheMapSmith/9b9bb0244cff8967e85d1655f6041027 to your computer and use it in GitHub Desktop.
Example S3 + MB Studio composite map
license: mit

An example showing two layers composited in mapbox.js/Leaflet:

  1. A baselayer drawing from raw .png tiles hosted on Amazon S3
  2. A reference layer drawing from a Mapbox Studio-designed vector tileset.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>External map layers</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = 'pk.eyJ1Ijoia2l2YWxpbmFhcmNoaXZlIiwiYSI6ImNqMDJ0ZmtwaDA4NG4zMm5oeGhyYWlycjIifQ.K1LN-TmgseciVeZcSDakQw';
var map = L.mapbox.map('map',null,{maxZoom: 8});
var geosprocketLayer = L.tileLayer('https://s3.amazonaws.com/geosprocket-basemap/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://geosprocket.com">Geosprocket</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.'
}).addTo(map);
var refLayer = L.tileLayer('https://api.mapbox.com/styles/v1/kivalinaarchive/cj04css02003l2rofygocarrv/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1Ijoia2l2YWxpbmFhcmNoaXZlIiwiYSI6ImNqMDJ0ZmtwaDA4NG4zMm5oeGhyYWlycjIifQ.K1LN-TmgseciVeZcSDakQw').addTo(map);
map.setView([68.020, -158.123], 5);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment