123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import Bus from "@/utils/bus";
- /**
- * 添加点
- * @param data
- * @param type 样式
- */
- export function addPoint(data: any, type = "custom") {
- 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"
- },
- "subobj": data.map((p: any) => createPointObj(p, type))
- }
- };
- Bus.emit('emitUIInteraction', descriptor)
- console.log("-- 添加点", JSON.stringify(descriptor));
- }
- /**
- * 删除点
- * @param type id,type,all
- * @param data
- */
- export function deletePoint(type: string, data: any) {
- let descriptor = {
- "command": "DelCustomPOI",
- "data": {}
- };
- if (type === "id") {
- descriptor.data = {
- "id": data,
- "all": "false"
- }
- } else if (type === 'type') {
- descriptor.data = {
- "id": data,
- "all": "false"
- }
- } else if (type === "all") {
- descriptor.data = {
- "all": "true"
- }
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log("-- 删除点", JSON.stringify(descriptor));
- }
- function createPointObj(point: any, type = "custom") {
- switch (type) {
- case 'video':
- 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": [
- {
- "text": [
- point.name,
- "fff",
- "12"
- ],
- "text_offset": "0,0",
- "text_boxwidth": 10,
- "text_centered": true,
- "scroll_speed": 1
- }
- ]
- },
- "marker": {
- "size": "40,40",
- "images": [
- {
- "define_state": "state_1",
- "normal_url": "TYPE3Blue.png",
- "activate_url": "TYPE3Blue.png"
- }
- ]
- }
- }
- case 'hydrologicStation':
- return {
- "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
- }
- ]
- },
- "marker": {
- "size": "20,20",
- "images": [
- {
- "define_state": "state_1",
- "normal_url": "TYPE4Blue.png",
- "activate_url": "TYPE4Blue.png"
- }
- ]
- }
- }
- case 'custom':
- default:
- return {
- "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
- }
- ]
- },
- "marker": {
- "size": "100,100",
- "images": [
- {
- "define_state": "state_1",
- "normal_url": "TYPE1Blue.png",
- "activate_url": "TYPE1Blue.png"
- }
- ]
- }
- }
- }
- }
|