|
@@ -4,34 +4,53 @@
|
|
|
<LayersTree :layer-data="mapLayers" class="project-layer-content" @check="checkLayer" @select="selectLayer"
|
|
<LayersTree :layer-data="mapLayers" class="project-layer-content" @check="checkLayer" @select="selectLayer"
|
|
|
v-model:selectedKeys="selectedKeys" v-model:checkedKeys="checkedKeys" />
|
|
v-model:selectedKeys="selectedKeys" v-model:checkedKeys="checkedKeys" />
|
|
|
</div>
|
|
</div>
|
|
|
- <a-drawer title="Map Element" placement="right" :closable="true" v-model:visible="visible" :mask="false"
|
|
|
|
|
|
|
+ <a-drawer title="地图元素" placement="right" :closable="true" v-model:visible="visible" :mask="false"
|
|
|
wrapClassName="drawer-element-wrapper" @close="closeDrawer" width="300">
|
|
wrapClassName="drawer-element-wrapper" @close="closeDrawer" width="300">
|
|
|
<div class="drawer-element-content">
|
|
<div class="drawer-element-content">
|
|
|
<div class="name element-item">
|
|
<div class="name element-item">
|
|
|
- <span class="title">Name:</span>
|
|
|
|
|
- <a-input v-model:value="layerState.layerName" style="width:120px" placeholder="element name"
|
|
|
|
|
|
|
+ <span class="mr30">名称:</span>
|
|
|
|
|
+ <a-input v-model:value="layerState.layerName" style="width:110px" placeholder="element name"
|
|
|
@change="changeLayer" />
|
|
@change="changeLayer" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="longitude element-item" v-if="layerState.currentType === geoType.Point">
|
|
<div class="longitude element-item" v-if="layerState.currentType === geoType.Point">
|
|
|
- <span class="title">Longitude:</span>
|
|
|
|
|
- <a-input v-model:value="layerState.longitude" style="width:120px" placeholder="longitude"
|
|
|
|
|
- @change="changeLayer" />
|
|
|
|
|
|
|
+ <span class="mr30">经度:</span>
|
|
|
|
|
+ {{ layerState.longitude || '--' }}
|
|
|
</div>
|
|
</div>
|
|
|
<div class="latitude element-item" v-if="layerState.currentType === geoType.Point">
|
|
<div class="latitude element-item" v-if="layerState.currentType === geoType.Point">
|
|
|
- <span class="title">Latitude:</span>
|
|
|
|
|
- <a-input v-model:value="layerState.latitude" style="width:120px" placeholder="latitude"
|
|
|
|
|
- @change="changeLayer" />
|
|
|
|
|
|
|
+ <span class="mr30">纬度:</span>
|
|
|
|
|
+ {{ layerState.latitude || '--' }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="latitude element-item" v-if="layerState.currentType === geoType.Point">
|
|
|
|
|
+ <span class="mr30">高度:</span>
|
|
|
|
|
+ {{ layerState.height || '--' }}
|
|
|
</div>
|
|
</div>
|
|
|
<div class="color-content">
|
|
<div class="color-content">
|
|
|
- <span class="mr30">Color: </span>
|
|
|
|
|
|
|
+ <span class="mr30">颜色: </span>
|
|
|
<div v-for="item in colors" :key="item.id" class="color-item" :style="'background:' + item.color"
|
|
<div v-for="item in colors" :key="item.id" class="color-item" :style="'background:' + item.color"
|
|
|
@click="changeColor(item)">
|
|
@click="changeColor(item)">
|
|
|
<svg-icon v-if="item.color === layerState.color" :size="18" name="check"></svg-icon>
|
|
<svg-icon v-if="item.color === layerState.color" :size="18" name="check"></svg-icon>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div class="element-item">
|
|
|
|
|
+ <span class="mr30">用户:</span>
|
|
|
|
|
+ {{ layerState.user_name || '--' }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="element-item">
|
|
|
|
|
+ <span class="mr30">来源:</span>
|
|
|
|
|
+ <Icon v-if="layerState.element_from === 2">
|
|
|
|
|
+ <template #component>
|
|
|
|
|
+ <svg width="1em" height="1em" fill="currentColor" viewBox="0 0 1024 1024">
|
|
|
|
|
+ <path
|
|
|
|
|
+ d="M1024 418.21v576H0v-576h1024z m-672 192c-53.02 0-96 42.98-96 96s42.98 96 96 96 96-42.98 96-96-42.98-96-96-96z m320 0c-53.02 0-96 42.98-96 96s42.98 96 96 96 96-42.98 96-96-42.98-96-96-96zM236.59 29.79h125.55v320H236.59v-320z m425.28 0h125.55v320H661.87v-320z"
|
|
|
|
|
+ p-id="4408" />
|
|
|
|
|
+ </svg>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </Icon>
|
|
|
|
|
+ <DesktopOutlined v-else />
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="flex-row flex-justify-around flex-align-center mt20">
|
|
<div class="flex-row flex-justify-around flex-align-center mt20">
|
|
|
- <a-button type="primary" @click="deleteElement">Delete</a-button>
|
|
|
|
|
|
|
+ <a-button type="primary" @click="deleteElement">删除</a-button>
|
|
|
</div>
|
|
</div>
|
|
|
</a-drawer>
|
|
</a-drawer>
|
|
|
</div>
|
|
</div>
|
|
@@ -44,20 +63,37 @@ import {
|
|
|
getElementGroupsReq,
|
|
getElementGroupsReq,
|
|
|
updateElementsReq
|
|
updateElementsReq
|
|
|
} from '/@/api/layer'
|
|
} from '/@/api/layer'
|
|
|
|
|
+import Icon from '@ant-design/icons-vue';
|
|
|
|
|
+import { DesktopOutlined } from '@ant-design/icons-vue';
|
|
|
import LayersTree from '/@/components/LayersTree.vue'
|
|
import LayersTree from '/@/components/LayersTree.vue'
|
|
|
import { MapDoodleColor, MapElementEnum } from '/@/constants/map'
|
|
import { MapDoodleColor, MapElementEnum } from '/@/constants/map'
|
|
|
import { useGMapCover } from '/@/hooks/use-g-map-cover'
|
|
import { useGMapCover } from '/@/hooks/use-g-map-cover'
|
|
|
-import { getRoot } from '/@/root'
|
|
|
|
|
import { useMyStore } from '/@/store'
|
|
import { useMyStore } from '/@/store'
|
|
|
import { GeojsonCoordinate, LayerResource } from '/@/types/map'
|
|
import { GeojsonCoordinate, LayerResource } from '/@/types/map'
|
|
|
import { Color, GeoType } from '/@/types/mapLayer'
|
|
import { Color, GeoType } from '/@/types/mapLayer'
|
|
|
import { generatePoint } from '/@/utils/genjson'
|
|
import { generatePoint } from '/@/utils/genjson'
|
|
|
import { gcj02towgs84, wgs84togcj02 } from '/@/vendors/coordtransform'
|
|
import { gcj02towgs84, wgs84togcj02 } from '/@/vendors/coordtransform'
|
|
|
|
|
|
|
|
-const root = getRoot()
|
|
|
|
|
|
|
+interface Props {
|
|
|
|
|
+ mapClickId: string,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
+
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+watch(() => props.mapClickId, (newValue, oldValue) => {
|
|
|
|
|
+ if (newValue) {
|
|
|
|
|
+ selectedKey.value = newValue
|
|
|
|
|
+ selectedLayer.value = getCurrentLayer(selectedKey.value)
|
|
|
|
|
+ setBaseInfo()
|
|
|
|
|
+ visible.value = true
|
|
|
|
|
+ store.commit('SET_DRAW_VISIBLE_INFO', visible.value)
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const store = useMyStore()
|
|
const store = useMyStore()
|
|
|
-let useGMapCoverHook = useGMapCover(store)
|
|
|
|
|
-console.log('store', store)
|
|
|
|
|
|
|
+let useGMapCoverHook = useGMapCover()
|
|
|
const mapLayers = ref(store.state.Layers)
|
|
const mapLayers = ref(store.state.Layers)
|
|
|
const checkedKeys = ref<string[]>([])
|
|
const checkedKeys = ref<string[]>([])
|
|
|
const selectedKeys = ref<string[]>([])
|
|
const selectedKeys = ref<string[]>([])
|
|
@@ -66,14 +102,19 @@ const selectedLayer = ref<any>(null)
|
|
|
const visible = ref<boolean>(false)
|
|
const visible = ref<boolean>(false)
|
|
|
store.commit('SET_DRAW_VISIBLE_INFO', visible.value)
|
|
store.commit('SET_DRAW_VISIBLE_INFO', visible.value)
|
|
|
const geoType = GeoType
|
|
const geoType = GeoType
|
|
|
|
|
+
|
|
|
const layerState = reactive({
|
|
const layerState = reactive({
|
|
|
- layerName: '',
|
|
|
|
|
layerId: '',
|
|
layerId: '',
|
|
|
|
|
+ layerName: '',
|
|
|
longitude: 0,
|
|
longitude: 0,
|
|
|
latitude: 0,
|
|
latitude: 0,
|
|
|
- currentType: '', // “LineString”,"Polygon","Point"
|
|
|
|
|
- color: '#212121'
|
|
|
|
|
|
|
+ height: 0,
|
|
|
|
|
+ currentType: '',// “LineString”,"Polygon","Point"
|
|
|
|
|
+ color: '#212121',
|
|
|
|
|
+ user_name: '',
|
|
|
|
|
+ element_from: 1,// 1-web 2-遥控器
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
const colors = ref<Color[]>([
|
|
const colors = ref<Color[]>([
|
|
|
{ id: 1, name: 'BLUE', color: '#2D8CF0', selected: true },
|
|
{ id: 1, name: 'BLUE', color: '#2D8CF0', selected: true },
|
|
|
{ id: 2, name: 'GREEN', color: '#19BE6B', selected: false },
|
|
{ id: 2, name: 'GREEN', color: '#19BE6B', selected: false },
|
|
@@ -82,6 +123,7 @@ const colors = ref<Color[]>([
|
|
|
{ id: 5, name: 'RED', color: '#E23C39', selected: false },
|
|
{ id: 5, name: 'RED', color: '#E23C39', selected: false },
|
|
|
{ id: 6, name: 'NAME_DEFAULT', color: '#212121', selected: false }
|
|
{ id: 6, name: 'NAME_DEFAULT', color: '#212121', selected: false }
|
|
|
])
|
|
])
|
|
|
|
|
+
|
|
|
const scorllHeight = ref()
|
|
const scorllHeight = ref()
|
|
|
|
|
|
|
|
async function getAllElement() {
|
|
async function getAllElement() {
|
|
@@ -115,6 +157,7 @@ function setMapCoverByElement(elements: LayerResource[]) {
|
|
|
updateMapElement(element, name, color)
|
|
updateMapElement(element, name, color)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function updateMapElement(
|
|
function updateMapElement(
|
|
|
element: LayerResource,
|
|
element: LayerResource,
|
|
|
name: string,
|
|
name: string,
|
|
@@ -137,11 +180,12 @@ function updateMapElement(
|
|
|
useGMapCoverHook.updatePolygonElement(id, name, coordinates, color)
|
|
useGMapCoverHook.updatePolygonElement(id, name, coordinates, color)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function checkLayer(keys: string[]) {
|
|
function checkLayer(keys: string[]) {
|
|
|
console.log('checkLayer', keys, selectedKeys.value, checkedKeys.value)
|
|
console.log('checkLayer', keys, selectedKeys.value, checkedKeys.value)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function selectLayer(keys: string[], e) {
|
|
function selectLayer(keys: string[], e) {
|
|
|
- // console.log('selectLayer', e.node.eventKey, e.selected)
|
|
|
|
|
if (e.selected) {
|
|
if (e.selected) {
|
|
|
selectedKey.value = e.node.eventKey
|
|
selectedKey.value = e.node.eventKey
|
|
|
selectedLayer.value = getCurrentLayer(selectedKey.value)
|
|
selectedLayer.value = getCurrentLayer(selectedKey.value)
|
|
@@ -154,7 +198,6 @@ function selectLayer(keys: string[], e) {
|
|
|
function getCurrentLayer(id: string) {
|
|
function getCurrentLayer(id: string) {
|
|
|
const Layers = store.state.Layers
|
|
const Layers = store.state.Layers
|
|
|
const key = id.replaceAll('resource__', '')
|
|
const key = id.replaceAll('resource__', '')
|
|
|
- // console.log('selectedKey.value', selectedKey.value)
|
|
|
|
|
let layer = null
|
|
let layer = null
|
|
|
const findCan = function (V) {
|
|
const findCan = function (V) {
|
|
|
V.forEach(item => {
|
|
V.forEach(item => {
|
|
@@ -168,7 +211,6 @@ function getCurrentLayer(id: string) {
|
|
|
}
|
|
}
|
|
|
findCan(Layers)
|
|
findCan(Layers)
|
|
|
// const layer = Layers.find(item => item.elements.find(el => el.id === key))
|
|
// const layer = Layers.find(item => item.elements.find(el => el.id === key))
|
|
|
- console.log('layer', layer)
|
|
|
|
|
return layer
|
|
return layer
|
|
|
}
|
|
}
|
|
|
function setBaseInfo() {
|
|
function setBaseInfo() {
|
|
@@ -180,6 +222,9 @@ function setBaseInfo() {
|
|
|
layerState.layerName = layer.name
|
|
layerState.layerName = layer.name
|
|
|
layerState.layerId = layer.id
|
|
layerState.layerId = layer.id
|
|
|
layerState.color = layer.resource?.content.properties.color
|
|
layerState.color = layer.resource?.content.properties.color
|
|
|
|
|
+ layerState.user_name = layer.resource?.user_name
|
|
|
|
|
+ layerState.element_from = layer.element_from
|
|
|
|
|
+ layerState.height = layer.height
|
|
|
let coordinate: GeojsonCoordinate
|
|
let coordinate: GeojsonCoordinate
|
|
|
switch (geoType) {
|
|
switch (geoType) {
|
|
|
case GeoType.Point:
|
|
case GeoType.Point:
|
|
@@ -194,12 +239,14 @@ function setBaseInfo() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
const element = document.getElementsByClassName('scrollbar').item(0) as HTMLDivElement
|
|
const element = document.getElementsByClassName('scrollbar').item(0) as HTMLDivElement
|
|
|
const parent = element?.parentNode as HTMLDivElement
|
|
const parent = element?.parentNode as HTMLDivElement
|
|
|
scorllHeight.value = parent?.clientHeight - parent.firstElementChild!.clientHeight
|
|
scorllHeight.value = parent?.clientHeight - parent.firstElementChild!.clientHeight
|
|
|
getAllElement()
|
|
getAllElement()
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
function closeDrawer() {
|
|
function closeDrawer() {
|
|
|
store.commit('SET_DRAW_VISIBLE_INFO', false)
|
|
store.commit('SET_DRAW_VISIBLE_INFO', false)
|
|
|
selectedKeys.value = []
|
|
selectedKeys.value = []
|
|
@@ -216,7 +263,6 @@ async function deleteElement() {
|
|
|
const elementid = selectedLayer.value.id
|
|
const elementid = selectedLayer.value.id
|
|
|
|
|
|
|
|
await deleteElementReq(elementid, {}).then(async (res: any) => {
|
|
await deleteElementReq(elementid, {}).then(async (res: any) => {
|
|
|
- // console.log('delete element res:', res)
|
|
|
|
|
if (res.code !== 0) {
|
|
if (res.code !== 0) {
|
|
|
console.warn(res)
|
|
console.warn(res)
|
|
|
return
|
|
return
|
|
@@ -232,13 +278,24 @@ async function getElementGroups(type?: string) {
|
|
|
groupId: '',
|
|
groupId: '',
|
|
|
isDistributed: true
|
|
isDistributed: true
|
|
|
})
|
|
})
|
|
|
- mapLayers.value = result.data
|
|
|
|
|
|
|
+ mapLayers.value = result.data.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ elements: item.elements.map((o: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...o,
|
|
|
|
|
+ height: o.resource.content.geometry.coordinates[2]
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
mapLayers.value = updateWgs84togcj02()
|
|
mapLayers.value = updateWgs84togcj02()
|
|
|
if (type && type === 'init') {
|
|
if (type && type === 'init') {
|
|
|
store.dispatch('setLayerInfo', mapLayers.value)
|
|
store.dispatch('setLayerInfo', mapLayers.value)
|
|
|
}
|
|
}
|
|
|
store.commit('SET_LAYER_INFO', mapLayers.value)
|
|
store.commit('SET_LAYER_INFO', mapLayers.value)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
async function updateElements() {
|
|
async function updateElements() {
|
|
|
let content = null
|
|
let content = null
|
|
|
if (layerState.currentType === GeoType.Point) {
|
|
if (layerState.currentType === GeoType.Point) {
|
|
@@ -283,6 +340,7 @@ function updateWgs84togcj02() {
|
|
|
})
|
|
})
|
|
|
return layers
|
|
return layers
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function updateCoordinates(transformType: string, element: LayerResource) {
|
|
function updateCoordinates(transformType: string, element: LayerResource) {
|
|
|
const geoType = element.resource?.content.geometry.type
|
|
const geoType = element.resource?.content.geometry.type
|
|
|
const type = element.resource?.type as number
|
|
const type = element.resource?.type as number
|
|
@@ -378,7 +436,7 @@ function updateCoordinates(transformType: string, element: LayerResource) {
|
|
|
.color-content {
|
|
.color-content {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
- margin-top: 8px;
|
|
|
|
|
|
|
+ margin: 8px 0 10px;
|
|
|
|
|
|
|
|
.color-item {
|
|
.color-item {
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
@@ -387,7 +445,7 @@ function updateCoordinates(transformType: string, element: LayerResource) {
|
|
|
line-height: 18px;
|
|
line-height: 18px;
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
- margin-left: 5px;
|
|
|
|
|
|
|
+ margin-right: 5px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|