Platform
Solutions
Resources
Pricing
Sign in
Sign up
D3
Bring your data to life.
Workspace
Fork
Published
d3-tile
By
Mike Bostock
Edited
Aug 27, 2020
ISC
Fork of
Wrapped Tiles
•
2 forks
3 stars
Insert cell
Insert cell
map
=
svg
`<svg viewBox="0 0 ${
width
} ${
height
}">
${
tiles
.
map
(
(
[
x
,
y
,
z
]
,
i
,
{
translate
:
[
tx
,
ty
]
,
scale
:
k
}
)
=>
svg
`
<image xlink:href="${
url
(
x
,
y
,
z
)
}" x="${
(
x
+
tx
)
*
k
}" y="${
(
y
+
ty
)
*
k
}" width="${
k
}" height="${
k
}">
`
)
}
</svg>`
Insert cell
tiles
=
tile
(
)
Insert cell
tile
=
d3
.
tile
(
)
.
size
(
[
width
,
height
]
)
.
scale
(
projection
.
scale
(
)
*
2
*
Math
.
PI
)
.
translate
(
projection
(
[
0
,
0
]
)
.
map
(
Math
.
round
)
)
.
tileSize
(
512
)
Insert cell
projection
=
d3
.
geoMercator
(
)
.
scale
(
Math
.
pow
(
2
,
18
)
/
(
2
*
Math
.
PI
)
)
.
translate
(
[
width
/
2
,
height
/
2
]
)
.
center
(
[
-
122
,
37.7
]
)
Insert cell
path
=
d3
.
geoPath
(
projection
)
Insert cell
url
=
(
x
,
y
,
z
)
=>
`https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/${
z
}/${
x
}/${
y
}${
devicePixelRatio
>
1
?
"@2x"
:
""
}?access_token=pk.eyJ1IjoibWJvc3RvY2siLCJhIjoiY2s5ZWRlbTM4MDE0eDNocWJ2aXR2amNmeiJ9.LEyjnNDr_BrxRmI4UDyJAQ`
Insert cell
height
=
512
Insert cell
d3
=
require
(
"d3-geo@2"
,
"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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
map
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tiles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
projection
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
path
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
height
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML