Last active
August 29, 2015 14:03
-
-
Save glenrobertson/a3fbddb0e275a7db9260 to your computer and use it in GitHub Desktop.
Map with TMS params
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></title> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> | |
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/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"> | |
function getURLParameters() { | |
// http://stackoverflow.com/questions/8648892/convert-url-parameters-to-a-javascript-object | |
var search = location.search.substring(1); | |
return JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') | |
} | |
var map = new L.Map('map'), | |
cloudmadeUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', | |
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade'; | |
map.setView(new L.LatLng(37.7833, -122.4167), 13); | |
var baseLayer = new L.TileLayer(cloudmadeUrl, { attribution: cloudmadeAttribution}); | |
baseLayer.addTo(map); | |
var parameters = getURLParameters(); | |
var heatmapUrl = parameters.uri; | |
if (Object.keys(parameters).length > 1) { | |
heatmapUrl += '?'; | |
for(var k in parameters) { | |
if (k === 'uri') { continue; } | |
heatmapUrl += k + '=' + parameters[k] + '&'; | |
} | |
} | |
var overlayLayer = new L.TileLayer(heatmapUrl); | |
overlayLayer.addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment