|
@@ -5,13 +5,14 @@
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
import { convertCoord } from '@/utils/coordTransform'
|
|
import { convertCoord } from '@/utils/coordTransform'
|
|
|
|
|
+import { getMonitoringPointIcon } from '@/utils/gisMapColors'
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
points: { type: Array, default: () => [] },
|
|
points: { type: Array, default: () => [] },
|
|
|
lines: { type: Array, default: () => [] },
|
|
lines: { type: Array, default: () => [] },
|
|
|
center: { type: Object, default: () => ({ lng: 110.3965, lat: 28.4638 }) },
|
|
center: { type: Object, default: () => ({ lng: 110.3965, lat: 28.4638 }) },
|
|
|
zoom: { type: Number, default: 15 },
|
|
zoom: { type: Number, default: 15 },
|
|
|
- markerSize: { type: Number, default: 22 },
|
|
|
|
|
|
|
+ markerSize: { type: Number, default: 28 },
|
|
|
showMarkerName: { type: Boolean, default: true },
|
|
showMarkerName: { type: Boolean, default: true },
|
|
|
mapStyleId: { type: String, default: 'a0f4e6e6f9e7a6c5d8e7f7e7f7e7f7e5' }
|
|
mapStyleId: { type: String, default: 'a0f4e6e6f9e7a6c5d8e7f7e7f7e7f7e5' }
|
|
|
})
|
|
})
|
|
@@ -78,20 +79,32 @@ function clearScene() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+function createMarkerIcon(BMapGL, iconUrl, size) {
|
|
|
|
|
+ return new BMapGL.Icon(iconUrl, new BMapGL.Size(size, size), {
|
|
|
|
|
+ anchor: new BMapGL.Size(size / 2, size),
|
|
|
|
|
+ imageSize: new BMapGL.Size(size, size)
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function addPointMarker(BMapGL, point) {
|
|
function addPointMarker(BMapGL, point) {
|
|
|
if (!Number.isFinite(Number(point.lng)) || !Number.isFinite(Number(point.lat))) return
|
|
if (!Number.isFinite(Number(point.lng)) || !Number.isFinite(Number(point.lat))) return
|
|
|
const [lng, lat] = convertCoord(point.lng, point.lat)
|
|
const [lng, lat] = convertCoord(point.lng, point.lat)
|
|
|
const name = point.name || point.equipmentName || point.facilityName || point.label || ''
|
|
const name = point.name || point.equipmentName || point.facilityName || point.label || ''
|
|
|
|
|
+ const iconUrl = point.iconUrl || getMonitoringPointIcon(point)
|
|
|
const position = new BMapGL.Point(lng, lat)
|
|
const position = new BMapGL.Point(lng, lat)
|
|
|
- const marker = new BMapGL.Marker(position)
|
|
|
|
|
|
|
+ const marker = new BMapGL.Marker(position, {
|
|
|
|
|
+ icon: createMarkerIcon(BMapGL, iconUrl, props.markerSize),
|
|
|
|
|
+ enableDragging: false
|
|
|
|
|
+ })
|
|
|
marker.addEventListener('click', (event) => {
|
|
marker.addEventListener('click', (event) => {
|
|
|
event?.domEvent?.stopPropagation?.()
|
|
event?.domEvent?.stopPropagation?.()
|
|
|
emit('point-click', point)
|
|
emit('point-click', point)
|
|
|
})
|
|
})
|
|
|
mapInstance.addOverlay(marker)
|
|
mapInstance.addOverlay(marker)
|
|
|
overlays.push(marker)
|
|
overlays.push(marker)
|
|
|
|
|
+
|
|
|
if (props.showMarkerName && name) {
|
|
if (props.showMarkerName && name) {
|
|
|
- const label = new BMapGL.Label(`<div class="marker-text">${escapeHtml(name)}</div>`, {
|
|
|
|
|
|
|
+ const label = new BMapGL.Label(`<div class="gis-marker-label-text">${escapeHtml(name)}</div>`, {
|
|
|
position,
|
|
position,
|
|
|
offset: new BMapGL.Size(-90, -props.markerSize - 8)
|
|
offset: new BMapGL.Size(-90, -props.markerSize - 8)
|
|
|
})
|
|
})
|
|
@@ -128,7 +141,12 @@ function addLine(BMapGL, line) {
|
|
|
;[points[0], points[points.length - 1]].forEach((point, index) => {
|
|
;[points[0], points[points.length - 1]].forEach((point, index) => {
|
|
|
const [lng, lat] = convertCoord(point.lng, point.lat)
|
|
const [lng, lat] = convertCoord(point.lng, point.lat)
|
|
|
const position = new BMapGL.Point(lng, lat)
|
|
const position = new BMapGL.Point(lng, lat)
|
|
|
- const marker = new BMapGL.Marker(position)
|
|
|
|
|
|
|
+ const iconUrl = line.iconUrl || getMonitoringPointIcon(point)
|
|
|
|
|
+ const name = `${line.name || '供水管网'} ${index === 0 ? '起点' : '终点'}`
|
|
|
|
|
+ const marker = new BMapGL.Marker(position, {
|
|
|
|
|
+ icon: createMarkerIcon(BMapGL, iconUrl, props.markerSize),
|
|
|
|
|
+ enableDragging: false
|
|
|
|
|
+ })
|
|
|
marker.addEventListener('click', (event) => {
|
|
marker.addEventListener('click', (event) => {
|
|
|
event?.domEvent?.stopPropagation?.()
|
|
event?.domEvent?.stopPropagation?.()
|
|
|
emit('line-click', line)
|
|
emit('line-click', line)
|
|
@@ -137,8 +155,7 @@ function addLine(BMapGL, line) {
|
|
|
overlays.push(marker)
|
|
overlays.push(marker)
|
|
|
|
|
|
|
|
if (!props.showMarkerName) return
|
|
if (!props.showMarkerName) return
|
|
|
- const name = `${line.name || '供水管网'} ${index === 0 ? '起点' : '终点'}`
|
|
|
|
|
- const label = new BMapGL.Label(`<div class="marker-text">${escapeHtml(name)}</div>`, {
|
|
|
|
|
|
|
+ const label = new BMapGL.Label(`<div class="gis-marker-label-text">${escapeHtml(name)}</div>`, {
|
|
|
position,
|
|
position,
|
|
|
offset: new BMapGL.Size(-90, -props.markerSize - 8)
|
|
offset: new BMapGL.Size(-90, -props.markerSize - 8)
|
|
|
})
|
|
})
|
|
@@ -223,7 +240,16 @@ defineExpose({
|
|
|
background: #e9f0e5;
|
|
background: #e9f0e5;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.marker-text {
|
|
|
|
|
|
|
+</style>
|
|
|
|
|
+
|
|
|
|
|
+<style>
|
|
|
|
|
+.gis-marker-label {
|
|
|
|
|
+ border: none !important;
|
|
|
|
|
+ background: transparent !important;
|
|
|
|
|
+ padding: 0 !important;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.gis-marker-label-text {
|
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
|
width: 180px;
|
|
width: 180px;
|
|
|
margin-bottom: 4px;
|
|
margin-bottom: 4px;
|
|
@@ -241,21 +267,4 @@ defineExpose({
|
|
|
text-overflow: ellipsis;
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
white-space: nowrap;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-.marker-wrap {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: column;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-.marker-icon {
|
|
|
|
|
- display: block;
|
|
|
|
|
- object-fit: contain;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-.pipe-label {
|
|
|
|
|
- color: #2563eb;
|
|
|
|
|
- font-size: 12px;
|
|
|
|
|
- font-weight: 600;
|
|
|
|
|
-}
|
|
|
|
|
</style>
|
|
</style>
|