UNPKG

@react-native-kakao/navi

Version:
109 lines 2.89 kB
import { filterNonNullishKeys } from '@mj-studio/js-util'; import { kAssert } from '@react-native-kakao/core'; function getVehicleType(v) { if (v === 'First') { return 1; } if (v === 'Second') { return 2; } if (v === 'Third') { return 3; } if (v === 'Fourth') { return 4; } if (v === 'Fifth') { return 5; } if (v === 'Sixth') { return 6; } if (v === 'TwoWheel') { return 7; } return 1; } function getRpOption(v) { if (v === 'Fast') { return 1; } if (v === 'Free') { return 2; } if (v === 'Shortest') { return 3; } if (v === 'NoAuto') { return 4; } if (v === 'Wide') { return 5; } if (v === 'Highway') { return 6; } if (v === 'Normal') { return 8; } if (v === 'Recommended') { return 100; } return 100; } const KakaoNavi = { navigateTo: async ({ viaList, destination, option }) => { kAssert(viaList ? viaList.length <= 3 : true, '[navigateTo] viaList length should equal or less then 3.'); try { var _option$coordType; Kakao.Navi.start(filterNonNullishKeys({ name: destination.name, x: destination.x, y: destination.y, coordType: option === null || option === void 0 || (_option$coordType = option.coordType) === null || _option$coordType === void 0 ? void 0 : _option$coordType.toLowerCase(), vehicleType: option !== null && option !== void 0 && option.vehicleType ? getVehicleType(option.vehicleType) : undefined, rpOption: option !== null && option !== void 0 && option.rpOption ? getRpOption(option.rpOption) : undefined, routeInfo: option === null || option === void 0 ? void 0 : option.routeInfo, sX: option === null || option === void 0 ? void 0 : option.startX, sY: option === null || option === void 0 ? void 0 : option.startY, sAngle: option === null || option === void 0 ? void 0 : option.startAngle, returnUri: option === null || option === void 0 ? void 0 : option.returnUri, viaPoints: viaList === null || viaList === void 0 ? void 0 : viaList.map(v => ({ name: v.name, x: v.x, y: v.y })) })); return true; } catch (e) { return false; } }, shareTo: async ({ destination, option }) => { try { var _option$coordType2; Kakao.Navi.share(filterNonNullishKeys({ name: destination.name, x: destination.x, y: destination.y, coordType: option === null || option === void 0 || (_option$coordType2 = option.coordType) === null || _option$coordType2 === void 0 ? void 0 : _option$coordType2.toLowerCase() })); return true; } catch (e) { return false; } } }; export const { navigateTo, shareTo } = KakaoNavi; export default KakaoNavi; //# sourceMappingURL=index.web.js.map