@vuemap/vue-amap
Version:
高德地图vue3版本封装
85 lines (82 loc) • 2.34 kB
JavaScript
import { defineComponent, ref, openBlock, createElementBlock } from 'vue';
import '../../../../mixins/index.mjs';
import { buildProps } from '../../../../utils/buildHelper.mjs';
import VideoLayer from './VideoLayer.mjs';
import { useRegister } from '../../../../mixins/useRegister.mjs';
var script = /* @__PURE__ */ defineComponent({
...{
name: "ElAmapLayerVideo",
inheritAttrs: false
},
__name: "Video",
props: buildProps({
url: {
required: true,
type: String
},
// 视频地址
zooms: {
type: Array
},
// 支持的缩放级别范围,默认范围 [2-30]
bounds: {
type: [Array, Object]
},
// 图片的范围大小经纬度,如果传递数字数组类型: [minlng,minlat,maxlng,maxlat] 或 AMap.Bounds
opacity: {
type: Number
}
// 透明度,默认 1
}),
emits: ["init"],
setup(__props, { expose: __expose, emit: __emit }) {
const emits = __emit;
const videoRef = ref();
let $amapComponent;
const { $$getInstance, parentInstance } = useRegister((options, parentComponent) => {
return new Promise((resolve) => {
$amapComponent = new VideoLayer(options, videoRef.value);
parentComponent.addLayer($amapComponent.getLayer());
resolve($amapComponent);
});
}, {
emits,
destroyComponent() {
if ($amapComponent && (parentInstance == null ? void 0 : parentInstance.$amapComponent)) {
if (!(parentInstance == null ? void 0 : parentInstance.isDestroy)) {
$amapComponent.destroy();
parentInstance == null ? void 0 : parentInstance.$amapComponent.removeLayer($amapComponent.getLayer());
}
$amapComponent = null;
}
}
});
const $$play = () => {
$amapComponent.play();
};
const $$pause = () => {
$amapComponent.pause();
};
__expose({
$$getInstance,
$$play,
$$pause
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock(
"video",
{
ref_key: "videoRef",
ref: videoRef,
style: { "display": "none" },
muted: ""
},
null,
512
/* NEED_PATCH */
);
};
}
});
export { script as default };
//# sourceMappingURL=Video.vue2.mjs.map