Skip to content

TripsLayer

Example

Example Source Code
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

NameDescriptionTypeDefault
idLayer IDstring-
auto-highlightWhen this property is true and pickable is also true, the hovered object will be highlighted.booleanfalse
current-timeCurrent time.number0
dataSource data for the layer.string / IndexAny / AnyArr / Promise<any>''
get-colorColor information.string / AnyFunc / number[]'black'
get-timestampsFunction to retrieve timestamp information.AnyFunc-
get-pathFunction to retrieve path information.AnyFuncobject => object.path
get-widthWidth information.number / AnyNumberFunc100
highlight-colorThe color to blend with the original color of the highlighted object.string / number[][255, 255, 128, 1]
highlighted-object-indexThe index of the currently highlighted element.number-1
miter-limitApplies when joint-rounded is false.number4
cap-roundedWhether the line caps are rounded.booleanfalse
joint-roundedWhether the line joints are rounded.booleanfalse
opacityThe opacity of the layer (0-1).number1
pickableWhether the layer responds to mouse events. If false, the component will not emit mouse-related events.booleanfalse
showWhether the layer is visible.booleantrue
trail-lengthLength of the trail.number120
width-max-pixelsMaximum width in pixels.numberNumber.MAX_SAFE_INTEGER
width-min-pixelsMinimum width in pixels.number0
width-scaleA scaling factor applied to the width.number1
width-unitsUnits for the width: 'pixels' or 'meters'.string ('pixels', 'meters')'meters'

EVENTS

NameDescriptionParameters
createdInitialization complete event-
mousemove-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }
mouseleave--
click-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }

SLOTS

NameDescription

METHODS

NameDescriptionDefinition