|
@@ -1,11 +1,11 @@
|
|
|
-import Bus from "@/utils/bus";
|
|
|
+import Bus from '@/utils/bus'
|
|
|
|
|
|
const exitPoints = new Set()
|
|
|
|
|
|
let exitType: any = {
|
|
|
- "堤防": [],
|
|
|
- "视频点": [],
|
|
|
- "水文站": [],
|
|
|
+ 堤防: [],
|
|
|
+ 视频点: [],
|
|
|
+ 水文站: [],
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -13,7 +13,7 @@ let exitType: any = {
|
|
|
* @param data
|
|
|
* @param type 样式
|
|
|
*/
|
|
|
-export function addPoint(data: any, type = "堤防") {
|
|
|
+export function addPoint(data: any, type = '堤防') {
|
|
|
let hasPoints = data.filter((p: any) => exitPoints.has(p.id))
|
|
|
updatePoint(hasPoints, type)
|
|
|
|
|
@@ -23,25 +23,25 @@ export function addPoint(data: any, type = "堤防") {
|
|
|
}
|
|
|
|
|
|
let descriptor = {
|
|
|
- "command": "AddCustomPOI",
|
|
|
- "data": {
|
|
|
- "obj": {
|
|
|
- "coord_type": 0,
|
|
|
- "cad_mapkey": "",
|
|
|
- "coord_z": 0,
|
|
|
- "coord_z_type": 0,
|
|
|
- "always_show_label": false,
|
|
|
- "show_label_range": "0,6000",
|
|
|
- "sort_order": false,
|
|
|
- "animation_type": "bounce",
|
|
|
- "duration_time": 0.7,
|
|
|
- "state": "state_1"
|
|
|
+ command: 'AddCustomPOI',
|
|
|
+ data: {
|
|
|
+ obj: {
|
|
|
+ coord_type: 0,
|
|
|
+ cad_mapkey: '',
|
|
|
+ coord_z: 0,
|
|
|
+ coord_z_type: 0,
|
|
|
+ always_show_label: false,
|
|
|
+ show_label_range: '0,6000',
|
|
|
+ sort_order: false,
|
|
|
+ animation_type: 'bounce',
|
|
|
+ duration_time: 0.7,
|
|
|
+ state: 'state_1',
|
|
|
},
|
|
|
- "subobj": createPoints.map((p: any) => createPointObj(p, type))
|
|
|
- }
|
|
|
- };
|
|
|
+ subobj: createPoints.map((p: any) => createPointObj(p, type)),
|
|
|
+ },
|
|
|
+ }
|
|
|
Bus.emit('emitUIInteraction', descriptor)
|
|
|
- console.log("-- 添加点", JSON.stringify(descriptor));
|
|
|
+ console.log('-- 添加点', JSON.stringify(descriptor))
|
|
|
|
|
|
data.forEach((p: any) => {
|
|
|
exitPoints.add(p.id)
|
|
@@ -60,226 +60,248 @@ export function addPoint(data: any, type = "堤防") {
|
|
|
*/
|
|
|
export function deletePoint(type: string, data: any) {
|
|
|
let descriptor = {
|
|
|
- "command": "DelCustomPOI",
|
|
|
- "data": {}
|
|
|
- };
|
|
|
+ command: 'DelCustomPOI',
|
|
|
+ data: {},
|
|
|
+ }
|
|
|
|
|
|
- if (type === "id") {
|
|
|
+ if (type === 'id') {
|
|
|
descriptor.data = {
|
|
|
- "id": data,
|
|
|
- "all": "false"
|
|
|
+ id: data,
|
|
|
+ all: 'false',
|
|
|
}
|
|
|
exitPoints.delete(data)
|
|
|
} else if (type === 'type') {
|
|
|
descriptor.data = {
|
|
|
- "id": data,
|
|
|
- "all": "false"
|
|
|
+ id: data,
|
|
|
+ all: 'false',
|
|
|
}
|
|
|
exitType[data].forEach((id: any) => {
|
|
|
exitPoints.delete(id)
|
|
|
})
|
|
|
exitType[data] = []
|
|
|
- } else if (type === "all") {
|
|
|
+ } else if (type === 'all') {
|
|
|
descriptor.data = {
|
|
|
- "all": "true"
|
|
|
+ all: 'true',
|
|
|
}
|
|
|
exitPoints.clear()
|
|
|
exitType = {
|
|
|
- "堤防": [],
|
|
|
- "视频点": [],
|
|
|
- "水文站": [],
|
|
|
+ 堤防: [],
|
|
|
+ 视频点: [],
|
|
|
+ 水文站: [],
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Bus.emit('emitUIInteraction', descriptor)
|
|
|
- console.log("-- 删除点", JSON.stringify(descriptor));
|
|
|
+ console.log('-- 删除点', JSON.stringify(descriptor))
|
|
|
}
|
|
|
|
|
|
-function createPointObj(point: any, type = "堤防") {
|
|
|
+function createPointObj(point: any, type = '堤防') {
|
|
|
switch (type) {
|
|
|
case '视频点':
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "type": point.type,
|
|
|
- "coord": `${point.x}, ${point.y}`,
|
|
|
- "label": {
|
|
|
- "bg_size": "70,20",
|
|
|
- "bg_offset": "-35,-60",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ type: point.type,
|
|
|
+ coord: `${point.x}, ${point.y}`,
|
|
|
+ label: {
|
|
|
+ bg_size: '70,20',
|
|
|
+ bg_offset: '-35,-60',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- "marker": {
|
|
|
- "size": "40,40",
|
|
|
- "images": [
|
|
|
+ marker: {
|
|
|
+ size: '40,40',
|
|
|
+ images: [
|
|
|
{
|
|
|
- "define_state": "state_1",
|
|
|
- "normal_url": "TYPE3Blue.png",
|
|
|
- "activate_url": "TYPE3Blue.png"
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ define_state: 'state_1',
|
|
|
+ normal_url: 'TYPE3Blue.png',
|
|
|
+ activate_url: 'TYPE3Blue.png',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
}
|
|
|
case '水文站':
|
|
|
+ let image = 'TYPE4Blue.png'
|
|
|
+ if (point.status === 'max') {
|
|
|
+ image = 'TYPE4Red.png'
|
|
|
+ }
|
|
|
+ if (point.status === 'min') {
|
|
|
+ image = 'TYPE4Green.png'
|
|
|
+ }
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "type": point.type,
|
|
|
- "coord": `${point.x}, ${point.y}`,
|
|
|
- "label": {
|
|
|
- "bg_size": "120,50",
|
|
|
- "bg_offset": "-60,-70",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ type: point.type,
|
|
|
+ coord: `${point.x}, ${point.y}`,
|
|
|
+ label: {
|
|
|
+ bg_size: '120,50',
|
|
|
+ bg_offset: '-60,-70',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- "marker": {
|
|
|
- "size": "20,20",
|
|
|
- "images": [
|
|
|
+ marker: {
|
|
|
+ size: '20,20',
|
|
|
+ images: [
|
|
|
{
|
|
|
- "define_state": "state_1",
|
|
|
- "normal_url": "TYPE4Blue.png",
|
|
|
- "activate_url": "TYPE4Blue.png"
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ define_state: 'state_1',
|
|
|
+ normal_url: image,
|
|
|
+ activate_url: image,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
}
|
|
|
case '堤防':
|
|
|
default:
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "type": point.type,
|
|
|
- "coord": `${point.x}, ${point.y}`,
|
|
|
- "label": {
|
|
|
- "bg_size": "60,20",
|
|
|
- "bg_offset": "-25,-70",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ type: point.type,
|
|
|
+ coord: `${point.x}, ${point.y}`,
|
|
|
+ label: {
|
|
|
+ bg_size: '60,20',
|
|
|
+ bg_offset: '-25,-70',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- "marker": {
|
|
|
- "size": "100,100",
|
|
|
- "images": [
|
|
|
+ marker: {
|
|
|
+ size: '100,100',
|
|
|
+ images: [
|
|
|
{
|
|
|
- "define_state": "state_1",
|
|
|
- "normal_url": "TYPE1Blue.png",
|
|
|
- "activate_url": "TYPE1Blue.png"
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ define_state: 'state_1',
|
|
|
+ normal_url: 'TYPE1Blue.png',
|
|
|
+ activate_url: 'TYPE1Blue.png',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function updatePointObj(point: any, type = "堤防") {
|
|
|
+function updatePointObj(point: any, type = '堤防') {
|
|
|
switch (type) {
|
|
|
case '视频点':
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "label": {
|
|
|
- "bg_size": "70,20",
|
|
|
- "bg_offset": "-35,-60",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ label: {
|
|
|
+ bg_size: '70,20',
|
|
|
+ bg_offset: '-35,-60',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
}
|
|
|
case '水文站':
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "label": {
|
|
|
- "bg_size": "120,50",
|
|
|
- "bg_offset": "-60,-70",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ label: {
|
|
|
+ bg_size: '120,50',
|
|
|
+ bg_offset: '-60,-70',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
}
|
|
|
case '堤防':
|
|
|
default:
|
|
|
return {
|
|
|
- "id": point.id ? point.id : point.name,
|
|
|
- "label": {
|
|
|
- "bg_size": "60,20",
|
|
|
- "bg_offset": "-25,-70",
|
|
|
- "content": [
|
|
|
+ id: point.id ? point.id : point.name,
|
|
|
+ label: {
|
|
|
+ bg_size: '60,20',
|
|
|
+ bg_offset: '-25,-70',
|
|
|
+ content: [
|
|
|
{
|
|
|
- "text": [
|
|
|
- point.name,
|
|
|
- "fff",
|
|
|
- "12"
|
|
|
- ],
|
|
|
- "text_offset": "0,0",
|
|
|
- "text_boxwidth": 10,
|
|
|
- "text_centered": true,
|
|
|
- "scroll_speed": 1
|
|
|
- }
|
|
|
- ]
|
|
|
+ text: [point.name, 'fff', '12'],
|
|
|
+ text_offset: '0,0',
|
|
|
+ text_boxwidth: 10,
|
|
|
+ text_centered: true,
|
|
|
+ scroll_speed: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function updatePoint(data: any, type = "堤防") {
|
|
|
+function updatePoint(data: any, type = '堤防') {
|
|
|
if (!data || data.length === 0) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
let descriptor = {
|
|
|
- "command": "UpdateCustomPOILabel",
|
|
|
- "data": {
|
|
|
- "subobj": data.map((p: any) => updatePointObj(p, type))
|
|
|
- }
|
|
|
- };
|
|
|
+ command: 'UpdateCustomPOILabel',
|
|
|
+ data: {
|
|
|
+ subobj: data.map((p: any) => updatePointObj(p, type)),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ Bus.emit('emitUIInteraction', descriptor)
|
|
|
+ console.log('-- 更新点', JSON.stringify(descriptor))
|
|
|
+
|
|
|
+ // 更新点样式
|
|
|
+ updatePointStyle(data)
|
|
|
+}
|
|
|
+
|
|
|
+function updatePointStyle(data: any) {
|
|
|
+ if (!data || data.length === 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let descriptor = {
|
|
|
+ command: 'UpdateCustomPOIMarker',
|
|
|
+ data: {
|
|
|
+ subobj: data.map((p: any) => {
|
|
|
+ let image = 'TYPE4Blue.png'
|
|
|
+ if (p.status === 'max') {
|
|
|
+ image = 'TYPE4Red.png'
|
|
|
+ }
|
|
|
+ if (p.status === 'min') {
|
|
|
+ image = 'TYPE4Green.png'
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: p.id ? p.id : p.name,
|
|
|
+ marker: {
|
|
|
+ size: '20,20',
|
|
|
+ images: [
|
|
|
+ {
|
|
|
+ define_state: 'state_1',
|
|
|
+ normal_url: image,
|
|
|
+ activate_url: image,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ }
|
|
|
Bus.emit('emitUIInteraction', descriptor)
|
|
|
- console.log("-- 更新点", JSON.stringify(descriptor));
|
|
|
+ console.log('-- 更新点样式', JSON.stringify(descriptor))
|
|
|
}
|