-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathApp.tsx
82 lines (73 loc) · 2.46 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import "leaflet-defaulticon-compatibility";
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css";
import "leaflet/dist/leaflet.css";
import { isMobile } from "react-device-detect";
import { Helmet } from "react-helmet";
import {
AttributionControl,
GeoJSON,
LayersControl,
MapContainer,
ScaleControl,
TileLayer
} from "react-leaflet";
import { BottomLeftImages } from "./components/BottomLeftImages";
import { OverlayFeatureLayers } from "./components/OverlayFeatureLayers";
import csvFeatureCollections from "./generated/csv-feature-collections.json";
import config from "./generated/hazardmap-config.json";
import imageNames from "./generated/image-names.json";
import shikuchosonBoundary from "./generated/shikuchoson-boundary.json";
const bounds: [number, number][] = [
[shikuchosonBoundary.bbox[1], shikuchosonBoundary.bbox[0]],
[shikuchosonBoundary.bbox[3], shikuchosonBoundary.bbox[2]],
];
export const App = () => (
<>
<Helmet>
<title>{config.shikuchoson}ハザードマップ</title>
</Helmet>
<MapContainer
bounds={bounds}
maxBounds={bounds}
minZoom={5}
maxZoom={17} // ハザードマップポータルサイトのデータの最大ズームレベル
attributionControl={false}
style={{ height: "100vh" }}
>
<AttributionControl prefix={false} />
<ScaleControl position="bottomright" />
<TileLayer
url="https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png"
attribution='<a href="https://maps.gsi.go.jp/development/ichiran.html">国土地理院</a>'
/>
<GeoJSON
// @ts-ignore
data={shikuchosonBoundary.geometry}
style={{ fillOpacity: 0 }}
/>
<LayersControl position="topright" collapsed={isMobile}>
{config.tiles.map((tile) => (
<LayersControl.Overlay
key={tile.name}
name={tile.name}
checked={tile.checked}
>
<TileLayer
url={tile.url}
// @ts-ignore
opacity={tile.opacity || 0.75}
attribution={tile.attribution}
/>
</LayersControl.Overlay>
))}
<OverlayFeatureLayers
// @ts-ignore
featureCollections={csvFeatureCollections}
/>
</LayersControl>
{imageNames.length > 0 ? (
<BottomLeftImages imageNames={imageNames} collapsed={isMobile} />
) : null}
</MapContainer>
</>
);