Location
Adding Location tags to captured photos (EXIF) and videos (metadata)
Captured Photos (see "A Photo") and Videos (see "The Recorder") can contain Location tags in their EXIF flags or video metadata.
Dependency Required
Location requires react-native-vision-camera-location to be installed.
Get a Location
To get a Location, use a LocationManager from react-native-vision-camera-location:
const location = useLocation({ /* options */ })
useEffect(() => {
if (!location.hasPermission) {
location.requestPermission()
}
}, [location.hasPermission])
if (location.hasPermission) {
console.log(location.location)
}const locationManager = createLocationManager({ /* options */ })
if (locationManager.locationPermissionStatus !== 'authorized') {
const hasPermission = await locationManager.requestLocationPermission()
if (!hasPermission) return
}
await locationManager.startUpdating()
locationManager.addOnLocationChangedListener((location) => {
console.log(location)
})Manually creating a Location
Alternatively, you can create a custom Location using createLocation(...), which can be useful for testing or spoofing location:
const location = createLocation(48.2084, 16.3735)Adding Location tags to Photos
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 */}
)Adding Location tags to Videos
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
})