vue3 + openlayers---流动线条(含动画效果)

效果图
在这里插入图片描述

// 通过GeoJSON方式增加图层数据
const layer = new VectorLayer({
 source: new VectorSource({
   features: new GeoJSON().readFeatures(
     {
       type: 'FeatureCollection',
       features: [
         {
           type: 'Feature',
           geometry: {
             type: 'LineString',
             coordinates: [
               [117.283042, 31.86119],
               [121.687899486, 31.24916171]
             ]
           }
         }
       ]
     },
     {
       dataProjection: 'EPSG:4490',
       featureProjection: 'EPSG:3857'
     }
   )
 }),
 style: [
   new Style({
     stroke: new Stroke({
       color: '#f00',
       width: 3,
       lineDash: [0]
     })
   }),
   new Style({
     stroke: new Stroke({
       color: '#ff0',
       width: 3,
       lineDash: [20, 27]
     })
   })
 ]
})
window.olMap.addLayer(layer)
// 设置图层样式 通过定时器setInterval实现动画效果
layer.getSource().getFeatures().forEach((item) => {
   setInterval(() => {
     let style = item.getStyle()
     if (style == undefined) {
       item.setStyle([
         new Style({
           stroke: new Stroke({
             color: '#f00',
             width: 3
           })
         }),
         new Style({
           stroke: new Stroke({
             color: '#ff0',
             width: 3,
             lineDash: [20, 27],
             lineDashOffset: 0
           })
         })
       ])
     } else {
       let lineDashOffset = item.getStyle()[1].getStroke().getLineDashOffset()
       item.setStyle([
         new Style({
           stroke: new Stroke({
             color: '#f00',
             width: 3
           })
         }),
         new Style({
           stroke: new Stroke({
             color: '#ff0',
             width: 3,
             lineDash: [15, 15],
             lineDashOffset: lineDashOffset === 29 ? 0 : lineDashOffset + 1
           })
         })
       ])
     }
   }, 10)
 })

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Vue3中使用Ant Design Vue的样式,可以按照以下步骤进行操作: 1. 首先,在你的项目中安装Ant Design Vue组件库。你可以通过npm或者yarn进行安装,具体的安装命令可以在Ant Design Vue的官方文档中找到。 2. 在你的Vue组件中引入Ant Design Vue的样式文件。你可以在组件所在的Vue文件中使用import语句引入Ant Design Vue的样式文件。 例如,在你的Vue文件中添加以下代码: ```javascript <style lang="less" scoped> @import '~ant-design-vue/dist/antd.less'; </style> ``` 这将会导入Ant Design Vue的样式文件,并使它只在当前组件中生效。 3. 接下来,你可以根据需要自定义你的组件样式。你可以在style标签中使用普通的CSS语法来定义和修改组件的样式。 例如,你可以在style标签中添加以下代码来自定义一个按钮组件的样式: ```javascript <style lang="less" scoped> .my-button { border-radius: 10px; } </style> ``` 这将会给按钮组件添加一个圆角为10px的边框样式。 通过以上步骤,你就可以在Vue3中使用Ant Design Vue的样式了。记得按照官方文档中的指引导入需要的组件,并在模板中使用它们。如果你需要更多示例和帮助,可以参考官方文档或者Ant Design Vue的开源项目。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue3+ant design vue+ts实战【ant-design-vue组件库引入】](https://blog.csdn.net/XSL_HR/article/details/127396384)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [vue3+ant-design-vue按需加载组件](https://blog.csdn.net/qq_42263570/article/details/130143934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [vue3+element-plus的后台管理系统模板 和 vue3+ant-design-vue的后台管理系统模板](https://blog.csdn.net/qq_61233877/article/details/131008600)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值