{"version":3,"file":"TimeZoneSymbol.mjs","sources":["../../../../../../../packages/sdk/plugins/AreaView/layer/TimeZoneSymbol.ts"],"sourcesContent":["/*\n * @Author: Yolo\n * @Date: 2024-07-02 09:16:14\n * @Last Modified by: Yolo\n * @Last Modified time: 2024-07-02 09:21:34\n * @Desc 全球时区\n */\nimport L from 'leaflet'\nimport { CommUtils } from '@map-sdk/sdk/utils/CommUtils'\nimport { AreaViewBase } from '@map-sdk/sdk/plugins/AreaView/AreaViewBase'\nimport { timezones } from '@map-sdk/sdk/plugins/AreaView/layer/TimeZoneSymbolData'\nimport type { AreaViewBaseOptions } from '@map-sdk/sdk/plugins/AreaView/AreaViewBase'\nimport type { MyMap } from '@map-sdk/sdk/ShipxyAPISDK'\ninterface TimeZoneProperties {\n  zone: number\n}\ntype TimeZoneFeature = GeoJSON.Feature<GeoJSON.Polygon, TimeZoneProperties>\n\nclass TimeZoneSymbol extends AreaViewBase {\n  constructor(map: MyMap, options?: Partial<AreaViewBaseOptions>) {\n    super(map, { ...(options || {}), minzoom: 3 })\n    this._data = timezones\n  }\n  _show(): this {\n    if (!this._data) {\n      console.error('区域图形展示，请求无数据！')\n      return this\n    }\n\n    let color = '#666'\n    if (this._map.mapType === 'MT_SATELLITE') {\n      color = '#fff'\n    }\n\n    const commonOptions: L.GeoJSONOptions = {\n      style: {\n        color,\n        weight: 2,\n        fillColor: color,\n        fillOpacity: 0.2,\n      },\n      onEachFeature: (feature: TimeZoneFeature, layer: L.GeoJSON) => {\n        const popupContent = () => {\n          let html = '<div class=\"box\"><div class=\"title\">'\n          let addStr = '+'\n          if (feature.properties.zone < 0) {\n            addStr = '-'\n          }\n          html += `UTC(${addStr}${Math.abs(feature.properties.zone)})`\n          html += `<span>${CommUtils.dataFormat(\n            CommUtils.getTimeByTimeZone(feature.properties.zone),\n            'hh:mm'\n          )}</span></div></div>`\n          return html\n        }\n\n        layer.bindPopup(popupContent, {\n          className: 'time-popup',\n          closeButton: false,\n        })\n\n        layer.on('mousemove', () => {\n          layer.setStyle({\n            fillColor: '#ff4648',\n            fillOpacity: 0.5,\n          })\n          layer.openPopup()\n        })\n\n        layer.on('mouseout', () => {\n          layer.setStyle(\n            commonOptions.style || {\n              fillColor: color,\n              fillOpacity: 0.2,\n            }\n          )\n          layer.closePopup()\n        })\n      },\n    }\n\n    this._areaLayers.push(L.geoJSON(this._data, commonOptions).addTo(this._map))\n\n    return this\n  }\n}\n\nexport function timeZoneSymbol(\n  map: MyMap,\n  options?: Partial<AreaViewBaseOptions>\n): TimeZoneSymbol {\n  return new TimeZoneSymbol(map, options)\n}\n"],"names":["u","l","constructor","e","t","super","minzoom","this","_data","f","_show","_map","mapType","style","color","weight","fillColor","fillOpacity","onEachFeature","i","o","bindPopup","s","r","properties","zone","Math","abs","a","dataFormat","getTimeByTimeZone","className","closeButton","on","setStyle","openPopup","closePopup","_areaLayers","push","n","geoJSON","addTo","timeZoneSymbol","p"],"mappings":"wLAA6O,MAAMA,UAAUC,EAAE,WAAAC,CAAYC,EAAEC,GAAGC,MAAMF,EAAE,IAAIC,GAAG,GAAGE,QAAQ,IAAIC,KAAKC,MAAMC,CAAC,CAAC,KAAAC,GAAQ,IAAIH,KAAKC,MAAM,OAAuGD,KAAK,IAAIJ,EAAE,OAA2B,iBAApBI,KAAKI,KAAKC,UAA2BT,EAAE,QAAQ,MAAMC,EAAE,CAACS,MAAM,CAACC,MAAMX,EAAEY,OAAO,EAAEC,UAAUb,EAAEc,YAAY,IAAIC,cAAc,CAACC,EAAEC,KAAuPA,EAAEC,WAA5O,KAAK,IAAIC,EAAE,uCAAuCC,EAAE,IAAI,OAAOJ,EAAEK,WAAWC,KAAK,IAAIF,EAAE,KAAKD,GAAG,OAAOC,IAAIG,KAAKC,IAAIR,EAAEK,WAAWC,SAASH,GAAG,SAASM,EAAEC,WAAWD,EAAEE,kBAAkBX,EAAEK,WAAWC,MAAM,8BAA8BH,IAAiB,CAACS,UAAU,aAAaC,aAAY,IAAKZ,EAAEa,GAAG,aAAY,KAAKb,EAAEc,SAAS,CAAClB,UAAU,UAAUC,YAAY,KAAKG,EAAEe,eAAcf,EAAEa,GAAG,YAAW,KAAKb,EAAEc,SAAS9B,EAAES,OAAO,CAACG,UAAUb,EAAEc,YAAY,KAAKG,EAAEgB,kBAAiB,OAAO7B,KAAK8B,YAAYC,KAAKC,EAAEC,QAAQjC,KAAKC,MAAMJ,GAAGqC,MAAMlC,KAAKI,OAAOJ,IAAI,EAAS,SAASmC,EAAeC,EAAExC,GAAG,OAAO,IAAIH,EAAE2C,EAAExC,EAAE"}