123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- /**
- * 船舶地图组件功能,通过调用封装好的基础地图组件实现特定业务功能
- */
- import { fullExtent, clearMap, calculation, changeMap, setCamera,
- layerControl, layerQuery, addGraphic, draw, getDrawGeometry,
- addBoats, setBoatHistory, playBoatHistory, clearBoatHistory,
- getMapScale
- } from '@/utils/map/ArcgisUtil'
- import {GetHpjShip,GetBoatAISHistoryByMMSI} from "@/apis/ship";
- import {nextTick} from "vue";
- import bus from "@/utils/bus";
- let boatInterval;
- let showBoat = false;
- // 船舶定位
- export function locationBoat(mmsi,isShow){
- if(isShow){
- GetHpjShip().then(res=>{
- let data = res.Result.data
- let boats = {
- "scale": 2000,
- "goto": true,
- "data": []
- }
- for(let i=0;i<data.length;i++){
- if(data[i].DEVICEID == mmsi){
- let boat = {
- "mmsi": data[i].DEVICEID,
- "shipNameCn": data[i].BOATNAME,
- "shipTypeName": data[i].SHIPTYPENAME,
- "direction": data[i].DIRECTION,
- "velocity": data[i].VELOCITY,
- "shipBreadth": data[i].SHIPBREADTH,
- "shipLength": data[i].SHIPLENGTH,
- "mapx": data[i].MAPX,
- "mapy": data[i].MAPY
- }
- boats.data.push(boat)
- }
- }
- // console.log('定位:'+JSON.stringify(boats))
- addBoats(boats)
- })
- }else{
- if (!showBoat){
- clearMap({is_draw: false, is_search:false, layers: ['boatLayer']})
- }
- }
- }
- // 船舶撒点
- export function setBoat(isShow){
- if(isShow) {
- if (!showBoat){
- showBoat = true
- }else{
- return
- }
- onLocationBoat()
- if (boatInterval != null) {
- clearInterval(boatInterval)
- }
- boatInterval = setInterval(onLocationBoat, 10000)
- }else{
- if (showBoat){
- showBoat = false
- }
- if (boatInterval != null) {
- clearInterval(boatInterval)
- }
- clearMap({is_draw: false, is_search:true, layers: ['boatLayer','boatPathLayer']})
- }
- }
- // 加载船舶
- function onLocationBoat(){
- GetHpjShip().then(res=>{
- let data = res.Result.data
- let boats = {
- "scale": getMapScale(),
- "goto": false,
- "data": []
- }
- for(let i=0;i<data.length;i++){
- let boat = {
- "mmsi": data[i].DEVICEID,
- "shipNameCn": data[i].BOATNAME,
- "shipTypeName": data[i].SHIPTYPENAME,
- "direction": data[i].DIRECTION,
- "velocity": data[i].VELOCITY,
- "shipBreadth": data[i].SHIPBREADTH,
- "shipLength": data[i].SHIPLENGTH,
- "mapx": data[i].MAPX,
- "mapy": data[i].MAPY
- }
- boats.data.push(boat)
- }
- addBoats(boats)
- })
- }
- bus.on('playBoatPath', (params) => {
- nextTick(() => {
- setBoatPath(params)
- },{immediate: true});
- })
- // 设置船舶历史轨迹
- export function setBoatPath(data){
- GetBoatAISHistoryByMMSI({
- deviceId:data.mmsi,
- startTime:data.startTime,
- endTime:data.endTime
- }).then(res=>{
- let data = res.Result.data
- let historyPoints=[]
- for(let i=0;i<data.length;i++){
- let boat = {
- "gpsTime": data[i].GPSTIME,
- "mapx": data[i].MAPX,
- "mapy": data[i].MAPY
- }
- historyPoints.push(boat)
- }
- setBoatHistory(historyPoints)
- // setTimeout(function() {
- // playBoatHistory('start')
- // }, 5000);
- })
- }
- /**
- * 船舶轨迹播放
- * 开始:start,
- * 暂停:pause,
- * 继续:resume,
- * 停止:stop
- * @param type
- */
- bus.on('playBoatHistoryPath', (type) => {
- playBoatHistory(type)
- })
- /**
- * 清除船舶轨迹
- */
- export function clearBoatHistoryPath(){
- console.log('清除船舶')
- clearBoatHistory()
- }
|