{"version":3,"file":"NavigationalWarningService.mjs","sources":["../../../../../../packages/sdk/plugins/NavigationalWarning/NavigationalWarningService.ts"],"sourcesContent":["/*\n * @Author: Yolo\n * @Date: 2024-06-18 16:00:30\n * @Last Modified by: Yolo\n * @Last Modified time: 2024-06-18 16:32:33\n * @Desc 航行警告绘制\n */\n\nimport L from 'leaflet'\nimport { center, featureCollection, point } from 'turf'\nimport { CanvasShipUtils } from '@map-sdk/sdk/utils/CanvasShipUtils'\nimport { DrawManager } from '@map-sdk/sdk/plugins/Draw/Draw'\nimport { NavigationalWarningServiceData } from '@map-sdk/sdk/plugins/NavigationalWarning/NavigationalWarningServiceData'\nimport type { MyMap } from '@map-sdk/sdk/ShipxyAPISDK'\n\nexport class NavigationalWarningService {\n  private _map: MyMap\n  private data: any\n  private drawManager: DrawManager\n  constructor(map: MyMap, options?: any) {\n    this._map = map\n    this.data = options?.data || NavigationalWarningServiceData.data\n    this.drawManager = new DrawManager(this._map, {\n      pmConfig: {\n        position: 'topleft',\n        drawMarker: false,\n        drawCircleMarker: false,\n        drawCircle: false,\n        drawPolyline: false,\n        drawRectangle: false,\n        drawPolygon: false,\n        editMode: false,\n        dragMode: false,\n        cutPolygon: false,\n        drawText: false,\n        removalMode: false,\n        drawEllipse: false,\n        rotateMode: false,\n      },\n    })\n  }\n  show(data?: any[]) {\n    const list = data || this.data\n    // 绘制航行警告 重要航警\n    list.map((item: any, index: number) => {\n      const pointsStr = item.points_conv\n      const pointsArray = pointsStr.split(',')\n      let coordinates: any[] = []\n      const turfs: any[] = []\n\n      let tipHtm = '<div class=\"nav_tooltip_content nav_tooltip_content_yj\">'\n      tipHtm += `<div class=\"nav_from \">信息来源：${item.source}</div>`\n      tipHtm += `<div class=\"nav_title bd1\">${item.type}：${item.title}</div>`\n      tipHtm += `<div class=\"nav_content bd1\">${item.content}</div>`\n      tipHtm += `<div class=\"nav_time \">发布时间：${item.pub_time_conv}</div></div>`\n      for (let i = 0; i < pointsArray.length; i += 2) {\n        const { lat, lng } = CanvasShipUtils.GPSEncryptByMapToLatLng(\n          L.latLng(\n            Number.parseFloat(pointsArray[i]),\n            Number.parseFloat(pointsArray[i + 1])\n          ),\n          this._map\n        )\n        coordinates.push([lng, lat])\n        turfs.push(point([lng, lat]))\n      }\n      const features = featureCollection(turfs)\n\n      const markerContent = center(features)\n      coordinates = CanvasShipUtils.latlngsFrom180(coordinates)\n      this.drawManager._DataEcho(item.layerId || index + 1, {\n        type: 'FeatureCollection',\n        features: [\n          {\n            type: 'Feature',\n            style: {\n              fillColor: '#FFFF00',\n              dashArray: [5, 5],\n              weight: 2,\n              opacity: 0.5,\n              color: '#FFF',\n              fillOpacity: 0.4,\n              // pane: 'tilePane',\n              className: 'nav-svg',\n            },\n            properties: {\n              name: '多边形绘制',\n            },\n            geometry: {\n              type: 'Polygon',\n              coordinates: [coordinates],\n            },\n          },\n          {\n            ...markerContent,\n            icon: L.icon({\n              iconUrl: 'https://cdn.xplusship.com/img/images/navwarn.png',\n              iconSize: [16, 16],\n              shadowSize: [0, 0],\n              iconAnchor: [8, 8],\n              shadowAnchor: [0, 0],\n              popupAnchor: [0, 0],\n            }),\n            showHtml: tipHtm,\n            properties: {\n              name: 'marker绘制区域',\n            },\n          },\n        ],\n      } as any)\n      return coordinates\n    })\n  }\n  hide(id?: string) {\n    this.drawManager.remove(id)\n  }\n}\n"],"names":["NavigationalWarningService","constructor","t","o","this","_map","data","M","drawManager","w","pmConfig","position","drawMarker","drawCircleMarker","drawCircle","drawPolyline","drawRectangle","drawPolygon","editMode","dragMode","cutPolygon","drawText","removalMode","drawEllipse","rotateMode","show","map","a","m","s","points_conv","split","e","i","r","source","type","title","content","pub_time_conv","n","length","lat","l","lng","p","d","GPSEncryptByMapToLatLng","c","latLng","Number","parseFloat","push","h","v","g","y","f","latlngsFrom180","_DataEcho","layerId","features","style","fillColor","dashArray","weight","opacity","color","fillOpacity","className","properties","name","geometry","coordinates","icon","iconUrl","iconSize","shadowSize","iconAnchor","shadowAnchor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