Skip to content

VCustomLayer

VCustomLayer 组件用于添加自定义图层,可配置渲染模式和自定义渲染方法。

基础用法

使用 Threebox 插件将 3D 模型添加到地图,并使其场景相机与 Mapbox 相机保持同步。

API

customLayerProps

属性名说明类型默认值
renderingMode渲染模式enum2d
render渲染方法Function必填
prerender预渲染方法Function-
renderToTile渲染到瓦片方法Function-
shouldRerenderTiles是否重新渲染瓦片Function-
onAdd添加到地图时触发的回调方法Function-
onRemove从地图中移除时触发的回调方法Function-
slot图层槽位string-
order图层顺序number-

customLayerEmits

事件名说明回调参数
load图层加载完成时触发(e: CustomLayerLoadEvent) => true

类型定义

CustomLayerLoadEvent

layers/CustomLayer/CustomLayer.ts
typescript
export interface CustomLayerLoadEvent {
  layer: CustomLayerInterface
  source: undefined
  map: Map
}

CustomLayerRenderMethod

layers/CustomLayer/CustomLayer.ts
typescript
export type CustomLayerRenderMethod = (
  gl: WebGL2RenderingContext,
  matrix: Array<number>,
  projection?: ProjectionSpecification,
  projectionToMercatorMatrix?: Array<number>,
  projectionToMercatorTransition?: number,
  centerInMercator?: Array<number>,
  pixelsPerMeterRatio?: number
) => void

基于 MIT 许可发布