-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathapp.tsx
More file actions
58 lines (52 loc) · 1.19 KB
/
app.tsx
File metadata and controls
58 lines (52 loc) · 1.19 KB
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
import * as React from 'react';
import {useState, useCallback} from 'react';
import {createRoot} from 'react-dom/client';
import Map from 'react-map-gl';
import ControlPanel from './control-panel';
const MAPBOX_TOKEN = ''; // Set your mapbox token here
const initialViewState = {
latitude: 37.729,
longitude: -122.36,
zoom: 11,
bearing: 0,
pitch: 50
};
export default function App() {
const [settings, setSettings] = useState({
scrollZoom: true,
boxZoom: true,
dragRotate: true,
dragPan: true,
keyboard: true,
doubleClickZoom: true,
touchZoomRotate: true,
touchPitch: true,
minZoom: 0,
maxZoom: 20,
minPitch: 0,
maxPitch: 85
});
const updateSettings = useCallback(
(name, value) =>
setSettings(s => ({
...s,
[name]: value
})),
[]
);
return (
<>
<Map
initialViewState={initialViewState}
{...settings}
mapStyle="mapbox://styles/mapbox/dark-v9"
mapboxAccessToken={MAPBOX_TOKEN}
hash
/>
<ControlPanel settings={settings} onChange={updateSettings} />
</>
);
}
export function renderToDom(container) {
createRoot(container).render(<App />);
}