oak-common-aspect/lib/geo.js

20 lines
743 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.geoService = exports.registerGetMapService = void 0;
const assert_1 = require("oak-domain/lib/utils/assert");
let GetMapServiceFn = undefined;
function registerGetMapService(fn) {
GetMapServiceFn = fn;
}
exports.registerGetMapService = registerGetMapService;
async function geoService(options, context) {
(0, assert_1.assert)(GetMapServiceFn, '未注入指定的GetMapServiceFn');
const service = GetMapServiceFn(context);
if (!service) {
throw new Error('找不到可用的地图服务,请检查初始化过程');
}
const { api, params } = options;
return await service[api](params);
}
exports.geoService = geoService;