{"version":3,"file":"EarthQuakeAreaSymbol.mjs","sources":["../../../../../../../packages/sdk/plugins/AreaView/layer/EarthQuakeAreaSymbol.ts"],"sourcesContent":["import L from 'leaflet'\nimport { CanvasShipUtils } from '@map-sdk/sdk/utils/CanvasShipUtils'\nimport { AreaViewBase } from '@map-sdk/sdk/plugins/AreaView/AreaViewBase'\nimport { result } from '@map-sdk/sdk/plugins/AreaView/layer/EarthQuakeAreaSymbolData'\nimport type { AreaViewBaseOptions } from '@map-sdk/sdk/plugins/AreaView/AreaViewBase'\nimport type { MyMap } from '@map-sdk/sdk/ShipxyAPISDK'\n\nclass EarthQuakeAreaSymbol extends AreaViewBase {\n  earthQuakeGroup: L.LayerGroup | null = null\n  earthQuakeGroupClear = true\n  isInit = true\n  list: { [key: string]: any } = result.data\n\n  constructor(map: MyMap, options?: Partial<AreaViewBaseOptions>) {\n    super(map, { minzoom: 2, maxzoom: 18, ...options })\n    this._data = this.list\n  }\n\n  _show() {\n    if (!this.earthQuakeGroup)\n      this.earthQuakeGroup = L.layerGroup().addTo(this._map)\n    const bounds = L.latLngBounds(L.latLng(0, 0), L.latLng(0, 0))\n    const defaultLatLng = [\n      [46.164614, 63.586602],\n      [46.163023, 117.942464],\n      [23.079732, 117.949548],\n      [23.079732, 63.586602],\n    ]\n    defaultLatLng.forEach((p) => {\n      bounds.extend(L.latLng(p[0], p[1]))\n    })\n    this.list.forEach(\n      (obj: {\n        lat: number\n        lon: number\n        time_conv: any\n        m_conv: any\n        depth: any\n        location: any\n      }) => {\n        //points_conv:\"38.779167,120.070167\"\n        const point = [obj.lat / 1000000, obj.lon / 1000000]\n        const latlon = CanvasShipUtils.GPSEncryptByMapToLatLng(\n          L.latLng([point[0], point[1]]),\n          this._map\n        )\n        if (!bounds.contains(latlon)) {\n          const m = L.marker(latlon, {\n            icon: L.icon({\n              iconUrl: 'https://cdn.xplusship.com/img/images/earthQuake1.png',\n              iconSize: [20, 28], // size of the icon\n              shadowSize: [0, 0], // size of the shadow\n              iconAnchor: [10, 14], // point of the icon which will correspond to marker's location\n              shadowAnchor: [0, 0], // the same for the shadow\n              popupAnchor: [0, 0],\n            }),\n          })\n          let tipHtm = ''\n          tipHtm += '<div class=\"nav_tooltip_content\">'\n          tipHtm += '<div class=\"nav_from \">信息来源：中国地震台网中心</div>'\n          tipHtm += `<div class=\"earth_content\">发震时刻：${obj.time_conv}(UTC+8)</div>`\n          tipHtm += `<div class=\"earth_content\">纬度：${CanvasShipUtils.latFormatter(\n            point[0]\n          )}</div>`\n          tipHtm += `<div class=\"earth_content \">经度：${CanvasShipUtils.lngFormatter(\n            point[1]\n          )}</div>`\n          tipHtm += `<div class=\"earth_content\">震级(M)：${obj.m_conv}</div>`\n          tipHtm += `<div class=\"earth_content\">深度(km)：${obj.depth}</div>`\n          tipHtm += `<div class=\"nav_time \">参考位置：${obj.location}</div></div>`\n          m.bindTooltip(`<em></em>${tipHtm}`, {\n            direction: 'right',\n            permanent: false,\n            className: 'nav_tooltip',\n          })\n          this.earthQuakeGroup && this.earthQuakeGroup.addLayer(m)\n        }\n      }\n    )\n    this.earthQuakeGroupClear = false\n  }\n  _hide() {\n    if (this.earthQuakeGroup) this.earthQuakeGroup.clearLayers()\n    this.earthQuakeGroupClear = true\n  }\n}\n\nconst earthQuakeAreaSymbol = (\n  map: MyMap,\n  options?: Partial<AreaViewBaseOptions>\n) => new EarthQuakeAreaSymbol(map, options)\n\nexport { EarthQuakeAreaSymbol, earthQuakeAreaSymbol }\n"],"names":["c","m","constructor","r","l","super","minzoom","maxzoom","this","earthQuakeGroup","earthQuakeGroupClear","isInit","list","u","data","_data","_show","e","layerGroup","addTo","_map","latLngBounds","latLng","forEach","a","extend","i","lat","lon","p","o","GPSEncryptByMapToLatLng","contains","h","marker","icon","iconUrl","iconSize","shadowSize","iconAnchor","shadowAnchor","popupAnchor","t","time_conv","latFormatter","lngFormatter","m_conv","depth","location","bindTooltip","direction","permanent","className","addLayer","_hide","clearLayers","d","n","s"],"mappings":"uMAA4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