Skip to content

Instantly share code, notes, and snippets.

@mukhtyar
Last active August 1, 2017 17:35
Show Gist options
  • Save mukhtyar/2433563ccdb9abee2f9eef97f7bc3671 to your computer and use it in GitHub Desktop.
Save mukhtyar/2433563ccdb9abee2f9eef97f7bc3671 to your computer and use it in GitHub Desktop.
Cal-Adapt Vector Tiles with Mapzen's TangramGL
license: mit

Custom vector tiles With TangramGL

Setup for testing CalAdapt vector tiles with TangramGL.

<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Simple demo – Tangram</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.css" />
<style>
body {
margin: 0px;
border: 0px;
padding: 0px;
}
#map {
height: 100%;
width: 100%;
position: absolute;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- leaflet -->
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>
<!-- Main tangram library -->
<script src="https://mapzen.com/tangram/0.10/tangram.min.js"></script>
<!-- Demo setup -->
<script>
var map = L.map('map');
var layer = Tangram.leafletLayer({
scene: 'scene.yaml',
attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a> | &copy; OSM contributors | <a href="https://mapzen.com/" target="_blank">Mapzen</a>'
});
layer.addTo(map);
map.setView([40.70531887544228, -122], 5);
</script>
</body>
</html>
cameras:
camera1:
type: perspective
lights:
light1:
type: directional
direction: [0, 1, -.5]
diffuse: .3
ambient: 1
sources:
mapzen:
type: TopoJSON
url: https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson
url_params:
api_key: mapzen-tDHBHDp
max_zoom: 16
caladapt:
type: MVT
url: http://api.cal-adapt.org/vtiles/hydrounits/{z}/{x}/{y}.pbf
max_zoom: 16
layers:
hydrologicunit:
data: { source: caladapt }
draw:
polygons:
order: 2
color: 'red'
earth:
data: { source: mapzen }
draw:
polygons:
order: 1
color: '#ddeeee'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment