Last active
March 22, 2018 17:20
-
-
Save maptastik/c30137e4e8663debbf9987a40e8e62dc to your computer and use it in GitHub Desktop.
Playing w/ TangramJS: Raster tile labels and GeoJSON data
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>TangramJS - Mixing with raster tiles</title> | |
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
#map { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | |
<script src="https://unpkg.com/tangram/dist/tangram.min.js"></script> | |
<script> | |
var kentucky = [37.857507, -85.632935] | |
var map = L.map('map', { | |
center: kentucky, | |
zoom: 7, | |
}); | |
var layer = Tangram.leafletLayer({ | |
scene: 'scene.yaml' | |
}).addTo(map); | |
map.createPane('labels'); | |
map.getPane('labels').style.zIndex = 1000; | |
var labels = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', { | |
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="http://cartodb.com/attributions">CartoDB</a>', | |
subdomains: 'abcd', | |
maxZoom: 19 | |
}).addTo(map); | |
</script> | |
</body> | |
</html> |
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
sources: | |
counties: | |
type: GeoJSON | |
url: https://gist.githubusercontent.com/maptastik/df8e483d5ac1c6cae3dc4a7c02ea9039/raw/9cd46849bddcfa90aab240772a12275408d6d8d0/kyCounties.geojson | |
carto_nolabel: | |
type: Raster | |
url: http://a.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png | |
styles: | |
_alpha_polygons: | |
base: polygons | |
blend: multiply | |
layers: | |
counties: | |
data: {source: counties} | |
draw: | |
lines: | |
color: '#000000' | |
width: 1px | |
order: 2 | |
polygons: | |
style: _alpha_polygons | |
order: 2 | |
color: | | |
function() { | |
var cat = feature.CH00_10; | |
var color = cat >= 5 ? '#2196F3' : | |
cat < 5 && cat >= 1 ? '#90CAF9': | |
cat < 1 && cat > -1 ? '#FFFDE7': | |
cat <= -1 && cat > -5 ? '#ef9a9a': | |
cat <= -5 ? '#f44336': | |
'#000' | |
return color; | |
} | |
basemap: | |
data: {source: carto_nolabel} | |
draw: | |
raster: | |
order: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment