Tools 工具类

类型 / 参数 / 返回值 / 用法 · 右侧为本页导航

自定义 本库 API OL OpenLayers 融合 自定义与 OL 混用

Tools 工具类

Tools · Draw

new Draw(main, options?)

import { Draw } from '@its-cool/simple-map';
const draw = new Draw(map, {
  style: [{ 'stroke-color': '#f00', 'stroke-width': 2 }]
});

cancel() / clear() / remove(item) / destroy()

内部 _draw(callback, options) 不建议业务直接调用;由 Measure、DrawSearch、analysis 使用。options.typePoint / Line / Polygon 等。

Tools · Measure

new Measure(main)

measure(type)

map.measureTool.measure('area');
// 等价
map.measure('area');

Tools · DrawSearch

draw(searchCallback, param?)

map.drawSearchTool.draw((res, num) => console.log(res, num));

cancel() / clearFun()

取消 / 清理绘制查询。


Tools · Tip

new Tip(main, text)

import { Tip } from '@its-cool/simple-map';
const tip = new Tip(map, '请点击地图');
tip.changeText('请双击结束');
tip.destroy();

Tools · WriteServer

常用方法

insertFeature(type, attributes)

editor.insertFeature('Point', { objCode: 'N1', name: '新点' });

editFeature(type)

updateFeature(properties, type, editType)

deleteFeature(properties, type) / deleteFeatures(objCodes) / deleteEditFeature()

删除单个 / 批量 / 当前编辑要素。

save(properties?)

clearFeature() / clear() / deactivate()

清理要素或交互。

importData(data) / updateProperties(objCodes, properties)

导入与批量改属性。

selectFromLayer(layerCode, objCodes)

从业务层选中要素进入编辑。

getEditFeatures() / setEditFeatures(features)

读写当前编辑要素集合。

unionFeaturs()

合并要素(方法名保持源码拼写)。

const editor = map.writeServer({ addType: 'geoserver', layerCodes: ['valve'] });
editor.insertFeature('Point', { objCode: 'V9' });
// 用户改完几何后
editor.save();

Tools · Track

实例方法摘要

方法参数说明
drawTrackLine(list)Array<{gpsX,gpsY,uploadTime}>绘制轨迹
drawSegmentedTrackLine(list)Array<Array<point>>分段轨迹
setMarkers(startCoord, endCoord)number[], number[]起终点标记
play(index)number播放到进度索引
setMovePoint(bool)boolean移动点显隐
getSource()线图层 VectorSource
destroy()移除图层
const track = map.addTrack(() => {});
track.drawTrackLine([
  { gpsX: 13528400, gpsY: 3676400, uploadTime: '2024-01-01 10:00:00' },
  { gpsX: 13528600, gpsY: 3676600, uploadTime: '2024-01-01 10:10:00' }
]);
track.setMarkers([13528400, 3676400], [13528600, 3676600]);
track.play(0);

Tools · Inspection

方法说明
play(index)巡检播放
addTrack(list) / addTrackLine(list)添加轨迹
trackSearch(list, data, noLine?)轨迹缓冲查管网;data:1 管网巡检点 / 2 关键巡检点
circleSearch(coord)圆形搜索
moveCenter(coord)移动中心
addScope(options)添加范围
updatePipeDate(list)更新管线数据
destroy()销毁
const insp = map.pipeInspection(console.log, { cloudLayerCodes: ['hydrant'] });
insp.addTrackLine([{ x: 13528400, y: 3676400 }, { x: 13528500, y: 3676500 }]);

Tools · Profile

方法说明
addStartPoint()起点
addMidPoints(data)中间点
addEndPoint()终点
addLines(data)剖面线
const profile = map.pipeProfile(console.log, {
  pipeLayerCode: 'pipe',
  flowLayerCode: 'flow'
});
profile.addStartPoint();