vue-cesium
Version:
Vue 3.x components for CesiumJS.
31 lines (28 loc) • 1.16 kB
JavaScript
import { getCurrentInstance, inject } from 'vue';
import useLog from '../private/use-log.mjs';
import { vcKey } from '../../utils/config.mjs';
;
function useVueCesium(containerId) {
var _a, _b, _c;
const instance = getCurrentInstance();
const provides = (instance == null ? void 0 : instance.parent) === null ? instance.vnode.appContext && instance.vnode.appContext.provides : (_a = instance == null ? void 0 : instance.parent) == null ? void 0 : _a.provides;
if ((!provides || !(vcKey in provides)) && !containerId) {
containerId = "cesiumContainer";
}
const logger = useLog();
if (instance) {
if (containerId) {
const $vc = (_c = (_b = instance.appContext.config.globalProperties) == null ? void 0 : _b.$VueCesium) == null ? void 0 : _c[containerId];
if (!$vc) {
logger.warn(`Failed to get $vc, reason: vc-viewer with containerId: ${containerId} was not found.`);
}
return $vc;
} else {
return inject(vcKey);
}
} else {
logger.warn("VueCesium useVueCesium() can only be used inside setup().");
}
}
export { useVueCesium as default };
//# sourceMappingURL=index.mjs.map