new VideoMap(options)
Usage
import { VideoMap } from "@supermapgis/iclient-mapboxgl";
// 将上面 opencv 源码拷贝到本地路径引用
options.opencv = "your opencv path";
new VideoMap(options);
<script type="text/javascript" src="https://iclient.supermap.io/dist/mapboxgl/iclient-mapboxgl.js"></script>
<script type="text/javascript" src="https://iclient.supermap.io/web/libs/opencv/3.4/opencv.js"></script>
<script>
new mapboxgl.supermap.VideoMap(options);
</script>
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
参数
|
- Version:
- 11.2.0
Fires
- VideoMap#event:load
- VideoMap#event:videoparameterupdate
- VideoMap#event:play
- VideoMap#event:pause
- VideoMap#event:drawstart
- VideoMap#event:drawcreate
- VideoMap#event:drawupdate
- VideoMap#event:drawcancel
- VideoMap#event:drawclear
- VideoMap#event:drawmodechange
- VideoMap#event:drawselectionchange
- VideoMap#event:drawdelete
API Relations
Extends
Events
-
drawcancel
mapboxgl/mapping/VideoMap.js, line 678 -
取消当前标绘时触发。
- Version:
- 12.1.2
-
drawclear
mapboxgl/mapping/VideoMap.js, line 684 -
清空标绘结果时触发。
- Version:
- 12.1.2
-
drawcreate
mapboxgl/mapping/VideoMap.js, line 662 -
完成一个标绘要素时触发。
- Version:
- 12.1.2
Properties:
Name Type Description featureObject 新增的 GeoJSON Feature。
dataObject 当前全部标绘结果。
-
drawdelete
mapboxgl/mapping/VideoMap.js, line 705 -
删除选中要素时触发。
- Version:
- 12.1.2
Properties:
Name Type Description featuresArray 被删除的 GeoJSON Feature。
dataObject 删除后的全部标绘结果。
-
drawmodechange
mapboxgl/mapping/VideoMap.js, line 690 -
绘制模式变化时触发。
- Version:
- 12.1.2
Properties:
Name Type Description modestring UI 模式,
'simple_select'|'draw_point'|'draw_line_string'|'draw_polygon'。typestring | null GeoJSON 类型,
'Point'|'LineString'|'Polygon'|null。 -
drawselectionchange
mapboxgl/mapping/VideoMap.js, line 698 -
选中要素变化时触发,供后续要素编辑使用。
- Version:
- 12.1.2
Properties:
Name Type Description featuresArray 当前选中的 GeoJSON Feature。
-
drawstart
mapboxgl/mapping/VideoMap.js, line 655 -
开始标绘时触发。
- Version:
- 12.1.2
Properties:
Name Type Description typestring 标绘类型。
-
drawupdate
mapboxgl/mapping/VideoMap.js, line 670 -
标绘结果或绘制中的图形发生变化时触发,可用于同步到其它地图。
- Version:
- 12.1.2
Properties:
Name Type Description dataObject 已完成的 GeoJSON FeatureCollection。
liveObject 已完成图形加上当前草稿的 GeoJSON FeatureCollection。
-
load
mapboxgl/mapping/VideoMap.js, line 1041 -
视频地图加载完成时触发。此时可调用 addSource/addLayer 叠加矢量数据。
Properties:
Name Type Description mapmapboxgl.Map 底层 mapbox-gl 地图实例。
-
pause
mapboxgl/mapping/VideoMap.js, line 966 -
视频暂停时触发。
-
play
mapboxgl/mapping/VideoMap.js, line 959 -
视频开始播放时触发。
Methods
-
addControl(control, position){VideoMap}
mapboxgl/mapping/VideoMap.js, line 612 -
向视频地图添加 MapboxGL 控件。若控件实现了
setTarget且尚无目标,或实现了setVideoMap,会自动注入当前 VideoMap。Name Type Description controlObject MapboxGL IControl 控件。
positionstring 可选 MapboxGL 原生控件位置:
'top-left'|'top-right'|'bottom-left'|'bottom-right'。- Version:
- 12.1.2
Returns:
Type Description VideoMap this。 -
addLayer(layer, beforeId)
mapboxgl/mapping/VideoMap.js, line 312 -
添加图层。
Name Type Description layerObject 图层配置。
Name Type Description idstring 图层 id
typestring 图层类型
sourcestring | Object 数据源配置
filterArray 可选 过滤配置
layoutObject 可选 布局配置
paintObject 可选 绘制配置
maxzoomnumber 可选 最大级别
minzoomnumber 可选 最小级别
beforeIdstring 已经存在的图层 ID。
-
addSource(id, source)
mapboxgl/mapping/VideoMap.js, line 338 -
添加数据源。
Name Type Description idstring 数据源 id。
sourceObject 图层源配置。
Name Type Description typestring 只支持 geojson
dataObject geojson 数据。
-
cancelDraw()
mapboxgl/mapping/VideoMap.js, line 723 -
取消当前正在绘制的图形并退出标绘。
- Version:
- 12.1.2
-
changeDrawMode(mode, options)
mapboxgl/mapping/VideoMap.js, line 785 -
切换绘制模式。
direct_select预留给后续顶点编辑,当前按选中处理。Name Type Description modestring 'simple_select'|'draw_point'|'draw_line_string'|'draw_polygon'|'direct_select'。optionsObject 可选 模式参数,如
{ featureId }。- Version:
- 12.1.2
-
clearDraw()
mapboxgl/mapping/VideoMap.js, line 734 -
清空已标绘的点、线、面。
- Version:
- 12.1.2
-
deleteDraw(ids){Object}
mapboxgl/mapping/VideoMap.js, line 796 -
删除标绘要素。不传 ids 时删除当前选中要素。
Name Type Description idsstring | Array.<string> 可选 要素 id。
- Version:
- 12.1.2
Returns:
Type Description Object 删除后的 GeoJSON FeatureCollection。 -
destroy()
mapboxgl/mapping/VideoMap.js, line 819 -
销毁视频地图。
-
finishDraw(){Object|null}
mapboxgl/mapping/VideoMap.js, line 713 -
结束当前线或面标绘并保存图形。点标绘在单击时即完成,无需调用此方法。
- Version:
- 12.1.2
Returns:
Type Description Object | null 完成的 GeoJSON Feature。 -
getDrawData(){Object}
mapboxgl/mapping/VideoMap.js, line 745 -
获取已标绘要素的 GeoJSON(经纬度,EPSG:4326)。
- Version:
- 12.1.2
Returns:
Type Description Object GeoJSON FeatureCollection。 -
getDrawLiveData(){Object}
mapboxgl/mapping/VideoMap.js, line 755 -
获取已完成标绘加上当前草稿的 GeoJSON(经纬度,EPSG:4326),可用于同步到真实地图。
- Version:
- 12.1.2
Returns:
Type Description Object GeoJSON FeatureCollection。 -
getDrawMode(){string|null}
mapboxgl/mapping/VideoMap.js, line 765 -
获取当前标绘类型。未处于标绘状态时返回
null。- Version:
- 12.1.2
Returns:
Type Description string | null 'Point'|'LineString'|'Polygon'|null。 -
getDrawSelected(){Object}
mapboxgl/mapping/VideoMap.js, line 807 -
获取当前选中的标绘要素。
- Version:
- 12.1.2
Returns:
Type Description Object GeoJSON FeatureCollection。 -
getDrawUiMode(){string}
mapboxgl/mapping/VideoMap.js, line 775 -
获取当前绘制 UI 模式,对齐 mapbox-gl-draw。
- Version:
- 12.1.2
Returns:
Type Description string 'simple_select'|'draw_point'|'draw_line_string'|'draw_polygon'。 -
getSource(id){Object|undefined}
mapboxgl/mapping/VideoMap.js, line 358 -
获取数据源。视频地图 GeoJSON 数据源的 data 为 EPSG:4326 原始数据,其余行为保持 Mapbox source 兼容。
Name Type Description idstring 数据源 id。
Returns:
Type Description Object | undefined Mapbox source 或视频地图 GeoJSON source 代理。 -
getVideoBounds(options){Object|null}
mapboxgl/mapping/VideoMap.js, line 524 -
获取当前视频画面反投影到地面的覆盖多边形。 顶点顺序为左上 → 右上 → 右下 → 左下;坐标为 EPSG:4326,经纬度,环自动闭合。
Name Type Description optionsObject 可选 参数。
Name Type Description maxDistancenumber 可选 地面距离相机的最大长度,单位米(EPSG:3857);用于截断过远的地平线交点。
- Version:
- 12.1.2
Returns:
Type Description Object | null GeoJSON Polygon Feature,无法计算时返回 null。 -
on()
mapboxgl/mapping/VideoMap.js, line 226 -
- Version:
- 12.1.2
-
pause()
mapboxgl/mapping/VideoMap.js, line 591 -
暂停视频。
- Version:
- 12.1.2
-
paused(){boolean}
mapboxgl/mapping/VideoMap.js, line 602 -
获取当前视频播放状态。返回
true表示已暂停,返回false表示正在播放。- Version:
- 12.1.2
Returns:
Type Description boolean 视频是否暂停。 -
play()
mapboxgl/mapping/VideoMap.js, line 580 -
播放视频。推荐使用
VideoPlayControl提供圆形播放/暂停按钮。- Version:
- 12.1.2
-
removeControl(control){VideoMap}
mapboxgl/mapping/VideoMap.js, line 629 -
移除控件。
Name Type Description controlObject 已添加的控件。
- Version:
- 12.1.2
Returns:
Type Description VideoMap this。 -
removeLayer(id)
mapboxgl/mapping/VideoMap.js, line 548 -
移除图层。
Name Type Description idstring 图层 id。
-
removeSource(id)
mapboxgl/mapping/VideoMap.js, line 564 -
移除数据源。
Name Type Description idstring 数据源 id。
-
startDraw(type)
mapboxgl/mapping/VideoMap.js, line 645 -
开始点、线、面标绘。单击加点;线、面双击或调用
finishDraw结束当前图形。坐标会转换为真实地理坐标,并随相机更新重投影。推荐使用VideoMapDrawControl提供工具条。Name Type Description typestring 标绘类型,
'Point'|'LineString'|'Polygon'。- Version:
- 12.1.2
-
toSpatialCoordinate(lngLat){Array.<number>|null}
mapboxgl/mapping/VideoMap.js, line 449 -
将视频地图坐标(lngLat)转换为真实地理坐标(EPSG:3857)。
Name Type Description lngLatmapboxgl.LngLat 视频地图坐标。
Returns:
Type Description Array.<number> | null 真实地理坐标 [x, y, z](EPSG:3857),无法转换时返回 null。
Type Definitions
-
VideoParametersObject
-
视频地图配准参数(静态配准,相机位置固定)。
Properties:
Name Type Description pitchnumber 相机俯仰角,单位:度。
rollnumber 相机侧偏角,单位:度。
yawnumber 相机偏航角,单位:度。
xnumber 相机位置 x 坐标(投影至 EPSG:3857 后的横坐标)。
ynumber 相机位置 y 坐标(投影至 EPSG:3857 后的纵坐标)。
znumber 相机位置 z 坐标(投影至 EPSG:3857 后的高程)。
fovXnumber 相机水平视场角,单位:度。内部通过 videoWidth 与该值换算为水平焦距 fx。
fovYnumber 相机垂直视场角,单位:度。内部通过 videoHeight 与该值换算为垂直焦距 fy。
centerXnumber 相机主点(光轴与图像平面交点)的水平像素坐标。
centerYnumber 相机主点(光轴与图像平面交点)的垂直像素坐标。
-
VideoTimeParametersObject
-
动态视频配准参数(按视频时间动态更新相机位置)。
- Version:
- 12.1.2
Properties:
Name Type Description timenumber 视频时间戳,单位秒。用于按视频播放时间匹配对应的相机参数。
pitchnumber 相机俯仰角,单位:度。
rollnumber 相机侧偏角,单位:度。
yawnumber 相机偏航角,单位:度。
xnumber 相机位置 x 坐标(投影至 EPSG:3857 后的横坐标)。
ynumber 相机位置 y 坐标(投影至 EPSG:3857 后的纵坐标)。
znumber 相机位置 z 坐标(投影至 EPSG:3857 后的高程)。
fovXnumber 相机水平视场角,单位:度。内部通过 videoWidth 与该值换算为水平焦距 fx。
fovYnumber 相机垂直视场角,单位:度。内部通过 videoHeight 与该值换算为垂直焦距 fy。
centerXnumber 相机主点(光轴与图像平面交点)的水平像素坐标。
centerYnumber 相机主点(光轴与图像平面交点)的垂直像素坐标。