docs/content/docs/location.mdx
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
Captured Photos (see "A Photo") and Videos (see "The Recorder") can contain Location tags in their EXIF flags or video metadata.
[!DEPENDENCY] Location requires react-native-vision-camera-location to be installed.
To get a Location, use a LocationManager from react-native-vision-camera-location:
<Tabs items={["Hooks", "Imperative"]} groupId="hooks-or-imperative" persist> <Tab value="Hooks">
const location = useLocation({ /* options */ })
useEffect(() => {
if (!location.hasPermission) {
location.requestPermission()
}
}, [location.hasPermission])
if (location.hasPermission) {
console.log(location.location)
}
if (locationManager.locationPermissionStatus !== 'authorized') { const hasPermission = await locationManager.requestLocationPermission() if (!hasPermission) return }
await locationManager.startUpdating() locationManager.addOnLocationChangedListener((location) => { console.log(location) })
</Tab>
</Tabs>
#### Manually creating a Location
Alternatively, you can create a custom [`Location`](/api/react-native-vision-camera/hybrid-objects/Location) using [`createLocation(...)`](/api/react-native-vision-camera-location/functions/createLocation), which can be useful for testing or spoofing location:
```ts
const location = createLocation(48.2084, 16.3735)
To add a Location to a Photo, pass a custom location to capturePhoto(...):
const photoOutput = ...
const location = ...
const photo = await photoOutput.capturePhoto(
{ location: location },
{ /* callbacks */ }
)
To add a Location to a captured Video, pass a custom location to createRecorder(...):
const videoOutput = ...
const location = ...
const recorder = await videoOutput.createRecorder({
location: location
})