Skip to content

Instantly share code, notes, and snippets.

@glenrobertson
Last active December 26, 2019 23:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glenrobertson/9521870 to your computer and use it in GitHub Desktop.
Save glenrobertson/9521870 to your computer and use it in GitHub Desktop.
so tile much random wow
<!DOCTYPE html>
<html>
<head>
<title>Stupid Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<style type="text/css">
html, body, #map {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map = new L.Map('map');
map.setView(new L.LatLng(37.7883, -122.4167), 12);
L.TileLayer.Random = L.TileLayer.extend({
options: {
},
initialize: function (urls, options) {
L.TileLayer.prototype.initialize.call(this, options);
this._urls = urls;
},
getTileUrl: function (tilePoint) {
var i = parseInt(Math.random() * this._urls.length);
return L.Util.template(this._urls[i], L.extend({
s: this._getSubdomain(tilePoint),
z: tilePoint.z,
x: tilePoint.x,
y: tilePoint.y
}, this.options));
}
});
var urls = [
'http://{s}.tile.cloudmade.com/1a1b06b230af4efdbb989ea99e9841af/997/256/{z}/{x}/{y}.png',
'http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg',
'http://tile.stamen.com/toner/{z}/{x}/{y}.jpg',
'http://8bitcities.s3.amazonaws.com/{z}/{x}/{y}.png'
]
var baseLayer = new L.TileLayer.Random(urls);
baseLayer.addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment