|
@@ -208,7 +208,7 @@
|
|
|
>
|
|
|
<div>是否确定加载该预案到地图上?</div>
|
|
|
</Dialog>
|
|
|
- <LayerDetail v-if="showLayer" v-model="showLayer" :pattern-id="patternId" />
|
|
|
+ <LayerDetail v-if="showLayer" v-model="showLayer" :pattern-id="patternId" :showAnnotationName="showAnnotationName" @showAnnotationNameChange="showAnnotationNameChange" />
|
|
|
<!--协同标绘选择弹窗-->
|
|
|
<SelectPoltting v-if="showOnlinePlotting" v-model="showOnlinePlotting" @confirm="handleOpenPlotting" />
|
|
|
</template>
|
|
@@ -224,8 +224,7 @@ import { deepClone } from '@/utils';
|
|
|
import { useHistory } from '@/hooks/useHistory';
|
|
|
import {
|
|
|
changeVisibleClassification,
|
|
|
- closeCollaboration,
|
|
|
- createCollaboration, createPattern,
|
|
|
+ createCollaboration,
|
|
|
deleteClassificationCreate,
|
|
|
deletePatternById,
|
|
|
getPatternInfo,
|
|
@@ -281,6 +280,8 @@ let showTextEdit = ref(false);
|
|
|
let lnglat = ref([]);
|
|
|
// 协同
|
|
|
let collaboration = ref(false);
|
|
|
+// 协同 是否显示标注名称
|
|
|
+let showAnnotationName = ref(false);
|
|
|
let webSock;
|
|
|
// 分享
|
|
|
let shareState = reactive({
|
|
@@ -528,10 +529,12 @@ const initDrawMethod = (options) => {
|
|
|
data.image = data.iconName;
|
|
|
data.imageHover = data.iconName;
|
|
|
data.visible = true;
|
|
|
- obj.setLabel({
|
|
|
- content: '<div>' + data.title + '</div>',
|
|
|
- direction: 'top'
|
|
|
- });
|
|
|
+ if (showAnnotationName.value) {
|
|
|
+ obj.setLabel({
|
|
|
+ content: '<div>' + data.title + '</div>',
|
|
|
+ direction: 'top'
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
if (options.type == 'circle') {
|
|
|
data.center = [obj.getCenter().lng, obj.getCenter().lat];
|
|
@@ -591,6 +594,9 @@ const initDrawMethod = (options) => {
|
|
|
// 图片加载完成后,可以访问其 width 和 height 属性
|
|
|
const width = img.width;
|
|
|
const height = img.height;
|
|
|
+ if (showAnnotationName.value) {
|
|
|
+ options.showLabel = true;
|
|
|
+ }
|
|
|
const style = new Style({
|
|
|
image: new Icon({
|
|
|
src: options.icon,
|
|
@@ -599,14 +605,8 @@ const initDrawMethod = (options) => {
|
|
|
anchorYUnits: 'fraction',
|
|
|
size: [width, height],
|
|
|
scale: !!options.size[0] ? options.size[0] / width : 1
|
|
|
- })
|
|
|
- // text: new Text({
|
|
|
- // text: data.title, // 使用属性中的值作为文本
|
|
|
- // font: '14px sans-serif',
|
|
|
- // fill: new Fill({
|
|
|
- // color: '#ffff'
|
|
|
- // })
|
|
|
- // })
|
|
|
+ }),
|
|
|
+ text: mapUtils.getTextStyle(options)
|
|
|
});
|
|
|
feature.setStyle(style);
|
|
|
};
|
|
@@ -775,20 +775,30 @@ const handleUndo = () => {
|
|
|
}
|
|
|
};
|
|
|
// 移除所有覆盖物
|
|
|
-const removeAllOverlay = () => {
|
|
|
- overlays.forEach((item, index) => {
|
|
|
+const removeAllOverlay = (noClean) => {
|
|
|
+ overlays.forEach((item) => {
|
|
|
if (Array.isArray(item)) {
|
|
|
item.forEach((overlay) => {
|
|
|
// 移除地图上覆盖物
|
|
|
- map.remove(overlay);
|
|
|
+ if (mapStore.isAMap) {
|
|
|
+ map.remove(overlay);
|
|
|
+ } else {
|
|
|
+ mapUtils.getDrawVector()?.getSource()?.removeFeature(overlay);
|
|
|
+ }
|
|
|
});
|
|
|
} else {
|
|
|
// 移除地图上覆盖物
|
|
|
- map.remove(item);
|
|
|
+ if (mapStore.isAMap) {
|
|
|
+ map.remove(item);
|
|
|
+ } else {
|
|
|
+ mapUtils.getDrawVector()?.getSource()?.removeFeature(item);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
- overlays = [];
|
|
|
- overlaysData = [];
|
|
|
+ if (!noClean) {
|
|
|
+ overlays = [];
|
|
|
+ overlaysData = [];
|
|
|
+ }
|
|
|
};
|
|
|
// 根据索引移除覆盖物
|
|
|
const removeOverlayByIndex = (index: number) => {
|
|
@@ -967,18 +977,21 @@ const handleShareConfirm = (data) => {
|
|
|
};
|
|
|
const getWebSocketData = (data) => {
|
|
|
if (data && data.length > 0) {
|
|
|
+ // 已把图片转换为正确路径, 只有可见
|
|
|
const data2 = [];
|
|
|
+ // 图片未转换
|
|
|
const data3 = [];
|
|
|
data.forEach((item) => {
|
|
|
if (!!item.content) {
|
|
|
const parseContent = JSON.parse(item.content);
|
|
|
+ parseContent.showLabel = showAnnotationName.value;
|
|
|
+ data3.push(deepClone(parseContent));
|
|
|
if (parseContent.type === 'marker' && !!parseContent.icon) {
|
|
|
parseContent.icon = getImageUrl(parseContent.icon);
|
|
|
}
|
|
|
if (item.visible === '1') {
|
|
|
data2.push(parseContent);
|
|
|
}
|
|
|
- data3.push(parseContent);
|
|
|
}
|
|
|
});
|
|
|
const res = mapUtils.drawData(data2);
|
|
@@ -1105,6 +1118,21 @@ const clearData = () => {
|
|
|
overlays = [];
|
|
|
overlaysData = [];
|
|
|
};
|
|
|
+
|
|
|
+const showAnnotationNameChange = () => {
|
|
|
+ showAnnotationName.value = !showAnnotationName.value;
|
|
|
+ const data = deepClone(overlaysData);
|
|
|
+ data.forEach((item) => {
|
|
|
+ item.showLabel = showAnnotationName.value;
|
|
|
+ console.log(item.icon);
|
|
|
+ if (item.type === 'marker' && !!item.icon) {
|
|
|
+ item.icon = getImageUrl(item.icon);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const res = mapUtils.drawData(data);
|
|
|
+ removeAllOverlay(true);
|
|
|
+ overlays = res;
|
|
|
+};
|
|
|
onMounted(() => {
|
|
|
getTemplateTreeData();
|
|
|
getList();
|