Использование пути реагируемого маркера?Javascript

Форум по Javascript
Ответить
Anonymous
 Использование пути реагируемого маркера?

Сообщение Anonymous »

У меня есть проблема с отправкой пути к мрачному маркеру. My Path ImagePath: /storage/emult/0/android/data/th.co.test.onsitereportsystemapp/files/omorder/101/24/20250723_160818.jpg. Проблема в том, что он показывает ошибку AddTimeStampWithLocation: [Ошибка: Установите изображение!]. Как мне отправить путь? < /P>

Код: Выделить всё

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;
}
};
Я просто хочу, чтобы MarkedPath отобразил данные на изображении.

Подробнее здесь: https://stackoverflow.com/questions/797 ... age-marker
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»