npm.io
4.2.0 • Published 1 week ago

ol-plot

Licence
MIT
Version
4.2.0
Deps
1
Size
1.8 MB
Vulns
0
Weekly
0

ol-plot

OpenLayers 地图标绘 SDK,支持 OpenLayers 6.15–10.x、29 种标绘符号、控制点编辑、样式序列化和场景恢复。

安装

pnpm add ol ol-plot
import 'ol/ol.css'
import 'ol-plot/style.css'

import Plot, { PlotTypes } from 'ol-plot'

const plot = new Plot(map, {
  layerName: 'plot-layer',
  pointTolerance: 5,
  zIndex: 20
})

plot.plotDraw.activate(PlotTypes.ATTACK_ARROW)
plot.plotDraw.on('drawEnd', (event) => {
  if (event.feature) plot.plotEdit.activate(event.feature)
})

数据恢复

const snapshot = plot.plotUtils.getFeatures()
plot.plotUtils.removeAllFeatures()
plot.plotUtils.addFeatures(snapshot)

生命周期

plot.destroy()

完整指南、API、兼容矩阵与在线 Playground:https://sakitam-fdd.github.io/ol-plot/

License

MIT

Keywords