Platform
Docs
Resources
Blog
Pricing
Sign in
Sign up
Fil
Vocateur.
Workspace
Fork
Public
Geo
By
Fil
Edited
Fork of
D3 Vector Tiles (WIP)
•
1 fork
9 stars
Insert cell
Insert cell
Insert cell
land
=
(
{
type
:
"FeatureCollection"
,
features
:
d3
.
merge
(
tiles
.
map
(
d
=>
!
d
.
layers
.
earth
?
[
]
:
geojson
(
d
,
d
.
layers
.
earth
)
.
features
)
)
}
)
Insert cell
import
{
map
}
with
{
land
}
from
"@fil/base-map"
Insert cell
Insert cell
Insert cell
srcprojection
=
d3
.
geoMercator
(
)
.
scale
(
1024
/
(
2
*
Math
.
PI
)
)
.
translate
(
[
width
/
2
,
height
/
2
]
)
Insert cell
tiles
=
Promise
.
all
(
tile
(
)
.
map
(
async
(
d
)
=>
{
const
[
x
,
y
,
z
]
=
d
;
d
.
layers
=
new
VectorTile
(
new
Protobuf
(
await
d3
.
buffer
(
`https://tile.nextzen.org/tilezen/vector/v1/256/all/${
z
}/${
x
}/${
y
}.mvt?api_key=${
apikey
}`
)
.
catch
(
(
_
)
=>
(
{
}
)
)
)
)
.
layers
;
// Sign up for an API key: https://www.nextzen.org
return
d
;
}
)
)
Insert cell
tile
=
d3
.
tile
(
)
.
size
(
[
width
,
height
]
)
.
scale
(
srcprojection
.
scale
(
)
*
2
*
Math
.
PI
)
.
translate
(
srcprojection
(
[
0
,
0
]
)
)
Insert cell
function
geojson
(
[
x
,
y
,
z
]
,
layer
)
{
if
(
!
layer
)
return
;
const
features
=
new
Array
(
layer
.
length
)
;
for
(
let
i
=
0
;
i
<
layer
.
length
;
++
i
)
features
[
i
]
=
layer
.
feature
(
i
)
.
toGeoJSON
(
x
,
y
,
z
)
;
return
resample
(
{
type
:
"FeatureCollection"
,
features
}
)
;
}
Insert cell
Insert cell
VectorTile
=
(
await
require
(
"https://bundle.run/@mapbox/vector-tile@1.3.1"
)
)
.
VectorTile
Insert cell
Protobuf
=
require
(
"pbf@3.1.0/dist/pbf.js"
)
Insert cell
d3
=
require
(
"d3@7"
,
"d3-tile@1"
)
Insert cell
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.
Try it for free
Learn more