Class: MapVLayer

MapVLayer

new MapVLayer(map, dataSet, mapVOptions)

engineExtensions/mapV/MapVLayerPlugin.js, line 4

MapV 可视化覆盖层。

该类用于把 MapV 数据集叠加到 MapboxGL 原生地图对象上, 并在地图移动、旋转、缩放和尺寸变化时同步刷新画布位置与渲染结果。

Name Type Description
map Object

MapboxGL 原生地图对象。可通过 MapView#getInnerView() 获取。

dataSet Object

MapV 使用的数据集对象。

mapVOptions Object

MapV 图层初始化参数。

Author:
  • 基础平台/创新中心 潘卓然 ParnDeedlit
See:
Examples

ES5 引入方式

const { MapView } = zondy.mapboxgl
const { MapVLayer } = zondy.mapboxgl.layer

const mapView = new MapView('map', {
  center: [114.299, 30.584],
  zoom: 10
})

mapView.on('load', function () {
  const innerView = mapView.getInnerView()
  const options = {
    size: 13,
    gradient: {
      0.25: 'rgb(0,0,255)',
      0.55: 'rgb(0,255,0)',
      0.85: 'yellow',
      1.0: 'rgb(255,0,0)'
    },
    max: 60,
    animation: {
      type: 'time',
      stepsRange: {
        start: 0,
        end: 100
      },
      trails: 10,
      duration: 4
    },
    draw: 'heatmap'
  }

  const mapVLayer = new MapVLayer(innerView, dataSet, options)
  mapVLayer.update({
    data: dataSet,
    options
  })
})

ES6 引入方式

import { MapView, MapVLayer } from '@mapgis/webclient-mapboxgl-plugin'

const mapView = new MapView('map', {
  center: [114.299, 30.584],
  zoom: 10
})

mapView.on('load', function () {
  const innerView = mapView.getInnerView()
  new MapVLayer(innerView, dataSet, {
    draw: 'heatmap'
  })
})

Methods

addData(data, options)

engineExtensions/mapV/MapVLayerPlugin.js, line 243

向当前 MapV 图层追加数据。

Name Type Description
data Array | Object

需要追加的数据数组或数据集对象。

options Object 可选

本次追加数据时使用的附加渲染参数。

destroy()

engineExtensions/mapV/MapVLayerPlugin.js, line 515

销毁当前图层并释放事件与数据。

该方法与 remove 的处理效果一致。

draw(){void}

engineExtensions/mapV/MapVLayerPlugin.js, line 368

根据当前地图状态重绘一次 MapV 图层。

Returns:
Type Description
void

getData(){Object|undefined}

engineExtensions/mapV/MapVLayerPlugin.js, line 265

获取当前 MapV 图层维护的数据集对象。

Returns:
Type Description
Object | undefined 当前图层持有的 MapV 数据集对象。

hide()

engineExtensions/mapV/MapVLayerPlugin.js, line 387

隐藏当前 MapV 图层。

moveTo(layerID, before)

engineExtensions/mapV/MapVLayerPlugin.js, line 474

调整当前图层容器在 DOM 中的前后顺序。

Name Type Default Description
layerID String

参考图层对应的 DOM 元素 ID。

before Boolean true 可选

是否移动到参考图层之前。

remove()

engineExtensions/mapV/MapVLayerPlugin.js, line 501

移除当前图层并释放事件与数据。

该方法与 destroy 的处理效果一致,用于保持与常见图层接口习惯一致。

removeAllData()

engineExtensions/mapV/MapVLayerPlugin.js, line 298

移除当前图层中的全部数据。

removeData(filter)

engineExtensions/mapV/MapVLayerPlugin.js, line 278

按过滤函数移除部分数据。

过滤函数返回 true 的数据会被移除。

Name Type Description
filter function

数据过滤函数。

Example
filter: function(item){
  if (item.count > 10 && item.count < 50) {
    return true;
  } else {
    return false;
  }
}

show()

engineExtensions/mapV/MapVLayerPlugin.js, line 378

显示当前 MapV 图层。

update(opt)

engineExtensions/mapV/MapVLayerPlugin.js, line 396

更新当前 MapV 图层的数据和渲染参数。

Name Type Description
opt Object

更新参数对象。

Name Type Description
data Array | Object 可选

需要更新的数据数组或数据集对象。

options Object 可选

需要更新的渲染参数。

updateData(data, options)

engineExtensions/mapV/MapVLayerPlugin.js, line 254

更新当前 MapV 图层的数据集。

Name Type Description
data Array | Object

更新后的数据数组或数据集对象。

options Object 可选

本次更新使用的附加渲染参数。