Last active
December 26, 2019 23:24
-
-
Save glenrobertson/9521870 to your computer and use it in GitHub Desktop.
so tile much random wow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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