Published
Edited
Jan 26, 2020
Fork of Vector tiles
10 forks
44 stars
Insert cell
Insert cell
map = svg`<svg viewBox="0 0 ${width} ${height}" style="width:100%;height:auto;">${tile().map(([x, y, z]) => {
const buildings = svg`<path>`;
const water = svg`<path fill="none" stroke="cyan" stroke-width="0.5">`;
fetch(`https://tile.nextzen.org/tilezen/vector/v1/512/all/${z}/${x}/${y}.json?api_key=${key}`)
.then(response => response.json())
.then(data => {
buildings.setAttribute("d", path(data.buildings));
water.setAttribute("d", path({
type: "FeatureCollection",
features: data.water.features.filter(d => d.properties.boundary)
}));
});
return svg`${buildings}${water}`;
})}</svg>`
Insert cell
projection = d3.geoMercator()
.center([-122.4183, 37.7750])
.scale(Math.pow(2, 21) / (2 * Math.PI))
.translate([width * 0.60, height * 0.15])
Insert cell
tile = d3.tile()
.tileSize(512)
.size([width, height])
.scale(projection.scale() * 2 * Math.PI)
.translate(projection([0, 0]))
.zoomDelta(2)
Insert cell
key = "jdPwBXkWSB-v5_CPQYDiIQ" // Sign up for an API key: https://www.nextzen.org
Insert cell
path = d3.geoPath(projection)
Insert cell
width = 954
Insert cell
height = Math.round(width * 2)
Insert cell
d3 = require("d3-geo@1", "d3-tile@1")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more