Skip to content
Make with

@naivemap/maplibre-gl-echarts-layer

Apache ECharts lines and scatter charts on MapLibre

Maintained by naivemap (huangli)

A MapLibre GL JS custom layer that draws Apache ECharts Lines and Scatter series in map coordinates, for flow lines and point charts on a MapLibre map.

Quick start

npm install @naivemap/maplibre-gl-echarts-layer echarts@5 maplibre-gl@5
import maplibregl from 'maplibre-gl'
import 'maplibre-gl/dist/maplibre-gl.css'
import EChartsLayer from '@naivemap/maplibre-gl-echarts-layer'

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://tiles.openfreemap.org/styles/liberty',
  center: [0, 30],
  zoom: 1
})

map.on('load', () => {
  const option = {
    series: [{
      type: 'scatter',
      name: 'Cities',
      data: [
        [-74.006, 40.7128],
        [-0.1278, 51.5074],
        [139.6917, 35.6895]
      ],
      symbolSize: 10
    }]
  }

  map.addLayer(new EChartsLayer('echarts-layer', option))
})
Runs this code in your browser, in a new tab.
›Setup noteschecked with v0.2.1

The peer dependencies are maplibre-gl 4 or 5 and echarts 5, so the install pins both to version 5 and there is no setWorkerUrl call. The layer sets the series coordinate system for you; it suits scatter, effectScatter, and lines series with [lng, lat] data. Add it after the map's load event.

Other platforms are on SDKs.