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" } ] } } } }