<template>
  <div id="map"></div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue'
import map from './map'
import { WindLayer } from 'leaflet-wind'

// 初始化地图
let maps: map
onMounted(() => {
  maps = map.initGlobals('map')
  addOcean()

})

const addOcean = async () => {
  const data = await fetch('/current.json').then((res) => res.json())
  if (maps.map) {
    const windLayer = new WindLayer('current', data, {
      windOptions: {
        velocityScale: () => {
          return 1 / 10;
        },
        frameRate: 100,
        maxAge: 60,
        globalAlpha: 0.9, 
        paths: () => {
          return maps.map ? 4000 * Math.pow(1, maps.map.getZoom()) : 0
        },
        lineWidth: 5
      }
    })
    maps.map.addLayer(windLayer);
  }
}

</script>
<style>
#map {
  width: 100%;
  height: 100%;
}

</style>