Skip to content

Instantly share code, notes, and snippets.

@rochoa
Last active March 16, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rochoa/234560d2850b202d6780a1ba567d304a to your computer and use it in GitHub Desktop.
Save rochoa/234560d2850b202d6780a1ba567d304a to your computer and use it in GitHub Desktop.
[CARTO] Tangram basic
<!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-rc.1/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://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
<!-- Main tangram library -->
<script src="https://mapzen.com/tangram/0.8/tangram.min.js"></script>
<!-- Demo setup -->
<script>
var map = L.map('map');
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '<a href="http://carto.com">CARTO</a> © 2016',
maxZoom: 18
}).addTo(map);
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> | Based on <a href="https://github.com/tangrams/simple-demo">Tangram\'s Simple Demo</a>'
}).addTo(map);
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', {
attribution: '<a href="http://carto.com">CARTO</a> © 2016',
maxZoom: 18
}).setZIndex(3).addTo(map);
map.setView([44, -3], 5);
</script>
</body>
</html>
cameras:
camera1:
type: perspective
lights:
light1:
type: directional
direction: [0, 1, -.5]
diffuse: .3
ambient: 1
sources:
osm:
type: MVT
url: //rochoa.carto.com/api/v1/map/named/tpl_7d1c2e68_7342_11e6_a123_0e3ebc282e83/mapnik/{z}/{x}/{y}.mvt
layers:
world_borders_other_countries:
data:
source: osm
layer: layer0
filter: function() { return feature.name != 'France'; }
draw:
polygons:
color: red
world_borders_france:
data:
source: osm
layer: layer0
filter: { name: "France" }
draw:
polygons:
color: [255, 190, 0, .2]
populated_places_other_countries:
data:
source: osm
layer: layer1
filter: function() { return feature.adm0name != 'France'; }
draw:
points:
color: white
size: 12
populated_places_france:
data:
source: osm
layer: layer1
filter: { adm0name: "France" }
draw:
points:
color: black
size: 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment