Last active
December 8, 2015 07:36
-
-
Save mikelmaron/6035c33af4807149334f to your computer and use it in GitHub Desktop.
india-road-complete
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> | |
<meta charset='utf-8' /> | |
<title></title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.0/mapbox-gl.js'></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.0/mapbox-gl.css' rel='stylesheet' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
</head> | |
<body> | |
<style> | |
#features { | |
position: absolute; | |
top: 0; | |
right: 0; | |
height: 20px; | |
width: 300px; | |
overflow: auto; | |
background: rgba(255, 255, 255, 0.8); | |
} | |
</style> | |
<div id='map'></div> | |
<pre id='features'></pre> | |
<script> | |
mapboxgl.accessToken = 'pk.eyJ1IjoibWlrZWxtYXJvbiIsImEiOiJjaWZlY25lZGQ2cTJjc2trbmdiZDdjYjllIn0.Wx1n0X7aeCQyDTnK6_mrGw'; | |
mapboxgl.util.getJSON('https://api.mapbox.com/styles/v1/mikelmaron/cihwzxlmr00kp9nkp61406fkq?access_token=' + mapboxgl.accessToken, function (err, style) { | |
if (err) throw err; | |
style.layers.forEach(function (layer) { | |
layer.interactive = true; | |
}); | |
var map = new mapboxgl.Map({ | |
container: 'map', | |
style: style, | |
center: [80,22.511], | |
zoom: 4 | |
}); | |
map.on('mousemove', function (e) { | |
map.featuresAt(e.point, {radius: 5}, function (err, features) { | |
if (err) throw err; | |
for (i in features) { | |
if (features[i].properties.pctcmp_int == undefined) return; | |
document.getElementById('features').innerHTML = features[i].properties.name + " %" + features[i].properties.pctcmp_int + " complete"; | |
} | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment