-
-
Notifications
You must be signed in to change notification settings - Fork 937
Expand file tree
/
Copy pathMapFps.tsx
More file actions
48 lines (39 loc) · 1.2 KB
/
MapFps.tsx
File metadata and controls
48 lines (39 loc) · 1.2 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
import { useEffect, useState } from 'react';
import Mapbox from '@rnmapbox/maps';
import { Button } from '@rneui/base';
import sheet from '../../styles/sheet';
import { type ExampleWithMetadata } from '../common/ExampleMetadata'; // exclude-from-doc
const MapFps = () => {
const [frameRate, setFrameRate] = useState(60);
useEffect(() => {
Mapbox.locationManager.start();
return (): void => {
Mapbox.locationManager.stop();
};
}, []);
return (
<>
<Button
onPress={() => setFrameRate((fps) => (fps === 60 ? 10 : 60))}
title={frameRate === 60 ? '10 fps' : '60 fps'}
/>
<Mapbox.MapView
styleURL={Mapbox.StyleURL.Dark}
style={sheet.matchParent}
testID={'toggle-map-fps'}
preferredFramesPerSecond={frameRate}
>
<Mapbox.Camera followZoomLevel={12} followUserLocation />
<Mapbox.UserLocation />
</Mapbox.MapView>
</>
);
};
export default MapFps;
/* end-example-doc */
const metadata: ExampleWithMetadata['metadata'] = {
title: 'Map FPS',
tags: [],
docs: `Toggles preferredFramesPerSecond between 10 fps and 60 fps, move the map around to feel the difference.`,
};
MapFps.metadata = metadata;