vue3-openlayers 图标闪烁、icon闪烁、marker闪烁

本篇介绍一下使用vue3-openlayers 图标闪烁、icon闪烁、marker闪烁

1 需求

  • 图标闪烁、icon闪烁、marker闪烁

2 分析

图标闪烁、icon闪烁、marker闪烁使用ol-animation-fade组件

3 实现

<template>
  <ol-map
    :loadTilesWhileAnimating="true"
    :loadTilesWhileInteracting="true"
    style="width: 100%; height: 100%"
    ref="mapRef"
  >
    <ol-view ref="view" :center="center" :zoom="zoom" :projection="projection" />

    <ol-tile-layer>
      <ol-source-tianditu
        layerType="img"
        :projection="projection"
        :tk="key"
        :hidpi="true"
        ref="sourceRef"
      ></ol-source-tianditu>
    </ol-tile-layer>
    <ol-tile-layer>
      <ol-source-tianditu
        :isLabel="true"
        layerType="img"
        :projection="projection"
        :tk="key"
        :hidpi="true"
      ></ol-source-tianditu>
    </ol-tile-layer>
    <ol-vector-layer>
      <ol-source-vector>
				<ol-animation-fade :duration="1000" :repeat="Infinity">
          <ol-feature>
            <ol-geom-point
              :coordinates=" [110, 30]"
            ></ol-geom-point>
            <ol-style>
              <ol-style-icon :src="iconSrc" :scale="0.05"></ol-style-icon>
            </ol-style>
          </ol-feature>
					<ol-feature>
            <ol-geom-point
              :coordinates="[112.5, 31]"
            ></ol-geom-point>
            <ol-style>
              <ol-style-icon :src="iconSrc" :scale="0.05"></ol-style-icon>
            </ol-style>
          </ol-feature>
        </ol-animation-fade>
				<ol-animation-fade :duration="2000" :repeat="Infinity">
          <ol-feature>
            <ol-geom-point
              :coordinates="[111.3, 31]"
            ></ol-geom-point>
            <ol-style>
              <ol-style-icon :src="iconSrc" :scale="0.05"></ol-style-icon>
            </ol-style>
          </ol-feature>
					<ol-feature>
            <ol-geom-point
              :coordinates="[115.5, 32]"
            ></ol-geom-point>
            <ol-style>
              <ol-style-icon :src="iconSrc" :scale="0.05"></ol-style-icon>
            </ol-style>
          </ol-feature>
        </ol-animation-fade>
      </ol-source-vector>
    </ol-vector-layer>
  </ol-map>
</template>

<script setup lang="ts">
import iconSrc from '@/assets/image/truck.png';

const center = ref([121, 31]);
const projection = ref('EPSG:4326');
const zoom = ref(5);
const mapRef = ref();
const key = '替换为天地图key';
const sourceRef = ref(null);
</script>
<style scoped lang="scss"></style>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值