Class: EchartsLayer

EchartsLayer

new EchartsLayer(map, options)

engineExtensions/echarts/EchartsLayerPlugin.js, line 5

ECharts 可视化覆盖层。

该类用于把 ECharts 图表结果叠加到 MapboxGL 原生地图对象上, 并在地图平移、缩放和窗口尺寸变化时同步刷新坐标系与画布容器。

Name Type Description
map Object

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

options Object

ECharts 图层初始化参数,直接作为 chart.setOption 的输入配置。

Name Type Default Description
layerId String 'echartlayerdefaultid' 可选

图层容器元素 ID。

classId String 'echartlayerdefaultclass' 可选

图层容器样式类名。

Examples

ES5 引入方式

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

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

mapView.on('load', function () {
  const innerView = mapView.getInnerView()
  const echartsLayer = new EchartsLayer(innerView, {
    series: []
  }).addTo(innerView)

  echartsLayer.update({
    series: []
  })
})

ES6 引入方式

import { MapView, EchartsLayer } 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 EchartsLayer(innerView, {
    series: []
  }).addTo(innerView)
})

Methods

addTo(map){EchartsLayer}

engineExtensions/echarts/EchartsLayerPlugin.js, line 170

将当前 ECharts 覆盖层挂载到 MapboxGL 地图并建立视图联动。

Name Type Description
map Object

MapboxGL 原生地图对象。当前实现主要用于保持链式调用形式。

Returns:
Type Description
EchartsLayer 当前图层实例。

hide()

engineExtensions/echarts/EchartsLayerPlugin.js, line 278

隐藏当前 ECharts 图层。

remove(){EchartsLayer}

engineExtensions/echarts/EchartsLayerPlugin.js, line 287

移除并销毁当前 ECharts 图层。

该操作会解绑地图联动事件、清空图表内容并移除图层容器。

Returns:
Type Description
EchartsLayer 当前图层实例。

show()

engineExtensions/echarts/EchartsLayerPlugin.js, line 269

显示当前 ECharts 图层。

update(option)

engineExtensions/echarts/EchartsLayerPlugin.js, line 320

更新当前图层的 ECharts 配置。

该方法内部直接调用 chart.setOption, 适合在异步数据返回后增量刷新图表内容。

Name Type Description
option Object

ECharts 配置对象。

See: