index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- Browser Compatibility -->
<meta http-equiv="cleartype" content="on">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://mapzen.com/js/mapzen.css">
<style type="text/css">
body, html{
height: 700vh;
}
#map{
width: 100%;
height: 100vh;
position: absolute;
top: 200vh;
left: 0;
}
</style>
</head>
<body class="">
<div class="map-container">
<div class="spacer">
scroll scroll scroll...
</div>
<div id="map"></div>
<div class="spacer"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<script src="https://mapzen.com/tangram/tangram.min.js"></script>
<script src="https://mapzen.com/js/mapzen.js"></script>
<script>
$(function(){
var map = L.Mapzen.map('map', {
scene: L.Mapzen.BasemapStyles.Refill
})
map.setView([39.7274801, -94.9338338], 6);
//map.on('tangramloaded', function(){
//_.delay(function(){
var layer = Tangram.leafletLayer({
scene: 'data.yaml',
events: {
hover: function(selection){ console.log(selection);},
click: function(selection){ console.log(selection);}
}
});
layer.addTo(map);
//map.setView([39.7274801, -94.9338338], 5);
//}, 3000);
//});
});
</script>
</body>
</html>
data.yaml
sources:
lead-data:
type: MVT
url: http://www.reuters.com/investigates/graphics/lead-water/lead-tiles/{z}/{x}/{y}.pbf
max_zoom: 10
global:
match: "undefined"
lights:
light1:
type: directional
direction: [0, 1, -.5]
diffuse: .3
ambient: 1
styles:
lead-styles:
base: polygons
blend_order: 10
layers:
lead-data:
data: { source: lead-data }
draw:
lead-styles:
interactive: true
color: function(){
var a = feature.ACTUAL;
if(isNaN(a)){
return '#FAFAFA';
}else if(a < 5){
return '#CABDDC';
}else if( (a <= 10) && (a >= 5)){
return '#B19CC9';
}else if( (a <= 15) && (a > 10)){
return '#8D6EAE';
}else if( (a <= 20) && (a > 15)){
return '#653290';
}else if( (a <= 25) && (a > 20)){
return '#552479';
}else if( (a <= 30) && (a > 25)){
return '#360451';
}else if( a > 30 ){
return '#000000';
}
}
match:
filter: {JOINT: global.match }
draw:
polygons:
color: [1.0, 0, 0, .5]
zoomed-lines:
filter: { $zoom: { min: 7 } }
draw:
lines:
order: 50
color: '#FFFFFF'
width: 1px
normal-lines:
filter: { $zoom: { max: 6, min: 0 } }
draw:
lines:
width: 0px