@react-native-kakao/navi
Version:
React Native Kakao Navi SDK
117 lines (116 loc) • 3.12 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shareTo = exports.navigateTo = exports.default = void 0;
var _jsUtil = require("@mj-studio/js-util");
var _core = require("@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
}) => {
(0, _core.kAssert)(viaList ? viaList.length <= 3 : true, '[navigateTo] viaList length should equal or less then 3.');
try {
var _option$coordType;
Kakao.Navi.start((0, _jsUtil.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((0, _jsUtil.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;
}
}
};
const {
navigateTo,
shareTo
} = KakaoNavi;
exports.shareTo = shareTo;
exports.navigateTo = navigateTo;
var _default = exports.default = KakaoNavi;
//# sourceMappingURL=index.web.js.map