Created
February 1, 2019 18:31
-
-
Save makella/2f3fbc74e91b309e2dc522eff1078068 to your computer and use it in GitHub Desktop.
Manhattan buildings over the years
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>Manhattan buildings over the years | CARTO VL</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta charset="UTF-8"> | |
<script src="http://libs.cartocdn.com/carto-vl/v1.1.1/carto-vl.js"></script> | |
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js"></script> | |
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css" rel="stylesheet" /> | |
<style> | |
html, | |
body { | |
margin: 0; | |
} | |
#map { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
const map = new mapboxgl.Map({ | |
container: 'map', | |
style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', | |
center: [-73.954400, 40.763723], | |
zoom: 12 | |
}); | |
carto.setDefaultConfig({ | |
serverURL: 'https://{user}.carto.com' | |
}); | |
carto.setDefaultAuth({ | |
username: 'cartovl', | |
apiKey: 'default_public' | |
}); | |
const source = new carto.source.Dataset("mnmappluto"); | |
const viz = new carto.Viz(` | |
color: ramp(linear($yearbuilt,1900,2018),prism) | |
filter: $numfloors > 2 and animation(linear($yearbuilt,1900,2018), 20, fade(0.1, hold)) | |
strokeWidth: 0 | |
`); | |
const layer = new carto.Layer('layer', source, viz); | |
layer.addTo(map, 'watername_ocean'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment