UNPKG

@vuemap/vue-amap

Version:

高德地图vue3版本封装

82 lines (79 loc) 2.31 kB
import { defineComponent, openBlock, createElementBlock } from 'vue'; import '../../../../mixins/index.mjs'; import { buildProps } from '../../../../utils/buildHelper.mjs'; import '../../../../utils/index.mjs'; import { useRegister } from '../../../../mixins/useRegister.mjs'; import { loadScript } from '../../../../utils/util.mjs'; var script = /* @__PURE__ */ defineComponent({ ...{ name: "ElAmapLayerTiles3d", inheritAttrs: false }, __name: "Tiles3D", props: buildProps({ url: { type: String, required: true }, threeScriptUrl: { type: String, default: "//a.amap.com/jsapi_demos/static/data3d/lib/three.117.js" }, threeGltfLoader: { type: String, default: "//a.amap.com/jsapi_demos/static/data3d/lib/GLTFLoader.117.min.js" }, layerStyle: { type: Object } }), emits: ["init"], setup(__props, { expose: __expose, emit: __emit }) { const emits = __emit; let $amapComponent; const { $$getInstance, parentInstance } = useRegister((options, parentComponent) => { return new Promise((resolve) => { parentComponent.plugin(["AMap.3DTilesLayer"], () => { if (!window["THREE"]) { loadScript(options.threeScriptUrl, () => { loadScript(options.threeGltfLoader, () => { createLayer(options); resolve($amapComponent); }); }); } else { createLayer(options); resolve($amapComponent); } }); }); }, { emits, destroyComponent() { if ($amapComponent) { $amapComponent = null; } } }); const createLayer = (options) => { let layerStyle = {}; if (options.layerStyle) { layerStyle = JSON.parse(JSON.stringify(options.layerStyle)); } $amapComponent = new AMap["3DTilesLayer"]({ map: parentInstance == null ? void 0 : parentInstance.$amapComponent, url: options.url, // 3d Tiles 入口文件 style: layerStyle }); }; __expose({ $$getInstance }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div"); }; } }); export { script as default }; //# sourceMappingURL=Tiles3D.vue2.mjs.map