/
index.js
54 lines (47 loc) · 1.3 KB
/
index.js
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
import "mapbox-gl/dist/mapbox-gl.css"
import "./index.css"
import MapGL, {
FullscreenControl,
NavigationControl,
ScaleControl,
} from "@urbica/react-map-gl"
import {graphql} from "gatsby"
import React, {useState} from "react"
import {Tiles} from "../components/tiles"
const PageIndex = ({data: {statsHunters}}) => {
const [viewState, setViewState] = useState({
zoom: 8,
longitude: "1.1941289",
latitude: "43.5928275",
})
return (
<MapGL
style={{
height: "100vh",
}}
accessToken={process.env.GATSBY_MAPBOX_KEY}
latitude={viewState.latitude}
longitude={viewState.longitude}
zoom={viewState.zoom}
onViewportChange={(viewport) => setViewState(viewport)}
attributionControl={false}
>
<ScaleControl unit="metric" position="bottom-right" />
<NavigationControl showCompass showZoom position="top-right" />
<FullscreenControl position="top-right" />
<Tiles id="square" tiles={statsHunters.square} color="#428cf4" />
<Tiles id="cluster" tiles={statsHunters.cluster} color="#2ca57e" />
<Tiles id="tiles" tiles={statsHunters.tiles} color="#ff0000" />
</MapGL>
)
}
export default PageIndex
export const pageQuery = graphql`
query Index {
statsHunters {
square
tiles
cluster
}
}
`