Skip to content

Instantly share code, notes, and snippets.

@makella
Last active February 11, 2019 23:37
Show Gist options
  • Select an option

  • Save makella/8576e125d59e0fc21493c3cd5490baba to your computer and use it in GitHub Desktop.

Select an option

Save makella/8576e125d59e0fc21493c3cd5490baba to your computer and use it in GitHub Desktop.
image transitions 2
<!DOCTYPE html>
<html>
<head>
<title>Exported map | 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: [63.362376, 21.918047],
zoom: 3.5
});
carto.setDefaultConfig({
serverURL: 'https://{user}.carto.com'
});
carto.setDefaultAuth({
username: 'cartovl',
apiKey: 'default_public'
});
const source = new carto.source.Dataset("pop_density_points");
const viz = new carto.Viz(`
transform: [translate(0,0),rotate(now()*$dn*1.5)]
symbol: ramp(buckets(100*(0.5*now()%1 >0.5),[100]), [triangle,star])
color: opacity(ramp(linear($dn), prism),$dn/150)
width: scaled(ramp($dn,[5,40]),3.5)
order: desc(width())
`);
const layer = new carto.Layer('layer', source, viz);
layer.addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment