Skip to content

轨迹线路图层(TripsLayer)

示例

示例源码
vue
<template>
  <div style="height: 400px">
    <mb-map :zoom="10" :pitch="40" :center="[-73.9, 40.7]">
      <mb-trips-layer
        :data="__RESOURCE_URL__ + 'json/trips.json'"
        :get-path="(d) => d.path"
        :get-timestamps="(d) => d.timestamps"
        :trail-length="200"
        :current-time="currentTime"
      />
    </mb-map>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'

const currentTime = ref(0)

const loop = 1900
const animate = (timestamp: number) => {
  currentTime.value = (timestamp / 10) % loop
  requestAnimationFrame(animate)
}

onMounted(() => {
  animate(0)
})
</script>

API

PROPS

名称描述类型默认值
id图层Idstring-
auto-highlight本属性为true且pickable为true时,则会将鼠标悬浮选中的对象设为高亮booleanfalse
current-time当前时间number0
data图层源数据string / IndexAny / AnyArr / Promise<any>''
get-color颜色信息string / AnyFunc / number[]black
get-timestamps时间片信息AnyFunc-
get-path路径信息AnyFuncobject => object.path
get-width宽度信息number / AnyNumberFunc100
highlight-color要与高亮对象原始颜色进行混合(blend)的颜色值string / number[][255, 255, 128, 1]
highlighted-object-index高亮元素序号number-1
miter-limitrounded为false时生效number4
cap-rounded-booleanfalse
joint-rounded-booleanfalse
opacity透明度number1
pickable图层是否会响应鼠标事件,若为false,则组件不会emit鼠标相关事件booleanfalse
show是否显示booleantrue
trail-length-number120
width-max-pixels-numberNumber.MAX_SAFE_INTEGER
width-min-pixels-number0
width-scale-number1
width-units-string(pixels / meters)meters

EVENTS

名称描述参数
created初始化完成事件-
mousemove-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }
mouseleave--
click-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }

SLOTS

名称描述

METHODS

名称描述定义