Код: Выделить всё
export const addTimestampWithLocation = async (imagePath, options = {}) => {
try {
console.log('🖼 imagePath:', imagePath);
const exists = await RNFS.exists(imagePath);
console.log('✔ File exists:', exists);
if (!exists) throw new Error('Image file does not exist');
const hasPermission = await requestLocationPermission();
if (!hasPermission) throw new Error('Location permission not granted.');
const coords = await getCurrentPosition();
const address = await reverseGeocode(coords.latitude, coords.longitude);
const timestamp = moment().format('YYYY-MM-DD HH:mm:ss');
const text = `${timestamp}\n${address}`;
const srcPath = Platform.OS === 'android' ? `file:/${imagePath}` : imagePath;
console.log('📸 Final src:', srcPath);
console.log('📝 Text:', text);
const markedPath = await Marker.markText({
src: { uri: srcPath },
text,
position: options.position || 'bottomRight',
color: options.color || '#FFFFFF',
fontName: options.fontName || 'Arial-BoldItalicMT',
fontSize: options.fontSize || 32,
scale: 1,
quality: 100,
saveFormat: options.saveFormat || 'jpg',
});
const finalPath = Platform.OS === 'android' ? markedPath.replace('file://', '') : markedPath;
if (finalPath !== imagePath) {
await RNFS.copyFile(finalPath, imagePath);
}
return imagePath;
} catch (err) {
console.error('addTimestampWithLocation error:', err);
throw err;
}
};
Подробнее здесь: https://stackoverflow.com/questions/797 ... age-marker