Platform
Resources
Pricing
Sign in
Contact us
cieloazul310
Workspace
Fork
Published
By
cieloazul310
Edited
Feb 26, 2020
Insert cell
Insert cell
Insert cell
Insert cell
// 道路中心線: rdcl, 鉄道中心線: railcl, 河川中心線: rvrcl, 基盤地図情報: fdg
tileset
=
tilesets
.
fdg
Insert cell
center
=
[
140.475
,
36.375
]
Insert cell
viewZoom
=
16
Insert cell
Insert cell
Insert cell
d3
=
require
(
'd3'
)
Insert cell
d3fetch
=
require
(
"d3-fetch@1"
)
Insert cell
d3tile
=
require
(
'd3-tile'
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tau
=
2
*
Math
.
PI
Insert cell
zoomReducer
=
Math
.
pow
(
2
,
tileZoom
-
viewZoom
)
Insert cell
projection
=
d3
.
geoMercator
(
)
.
center
(
center
)
.
scale
(
256
*
Math
.
pow
(
2
,
viewZoom
)
/
tau
)
.
translate
(
[
size
.
width
/
2
,
size
.
height
/
2
]
)
Insert cell
path
=
d3
.
geoPath
(
)
.
projection
(
projection
)
Insert cell
Insert cell
Insert cell
tiles
=
d3tile
.
tile
(
)
.
size
(
[
size
.
width
*
zoomReducer
,
size
.
height
*
zoomReducer
]
)
.
scale
(
projection
.
scale
(
)
*
tau
*
zoomReducer
)
.
translate
(
projection
(
[
0
,
0
]
)
.
map
(
v
=>
v
*
zoomReducer
)
)
(
)
Insert cell
Insert cell
Insert cell
tasks
=
tiles
.
map
(
obj
=>
d3fetch
.
json
(
`${
tileset
.
url
}${
obj
[
2
]
}/${
obj
[
0
]
}/${
obj
[
1
]
}.geojson`
)
.
catch
(
(
)
=>
undefined
)
)
Insert cell
Insert cell
Insert cell
datasets
=
Promise
.
all
(
tasks
)
.
then
(
data
=>
data
.
filter
(
datum
=>
datum
!==
undefined
)
)
Insert cell
Insert cell
/*
{
const svg = d3.select(DOM.svg(size.width, size.height));
const g = svg.selectAll('.tile')
.data(datasets)
.enter()
.append('g')
.attr('class', 'tile');
g.selectAll('path')
.data(d => d.features)
.enter()
.append('path')
.attr('d', path)
.attr('fill', 'none')
.attr('stroke', 'silver')
.attr('stroke-width', 1);
return svg.node();
}
*/
/** 普通のJavaScriptであれば、Promise.all(tasks).then()の中に処理を書く
* Promise.all(tasks).then(data => {
* const g = svg.selectAll('.tile')...
* });
*/
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tileset
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
center
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
viewZoom
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3fetch
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3tile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
size
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tilesets
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tileZoom
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tau
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
zoomReducer
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tiles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tasks
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
datasets
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML