地图数据源
地图数据源(map-source-*)
数据源不渲染,只把不同来源的数据归一化成要素 / 记录供图层引用(图层监听源版本,源刷新即重渲)。放在 map-2d 的 pieces 里、图层之前。共 5 种。
图层如何引用数据源
图层设 data-input: "source" + data-source-uid: [{ refType: "element", targetPath: ["源piece的uid"] }],再用 src-* 把源记录字段映射成几何 / 属性。详见图层的数据来源。
发布为项目数据源
GeoJSON / 查询 / 动态源可设 source-publish: true + source-publish-name + source-publish-row-limit(默认 500),把源字段并入工程数据树,之后能被任意组件按字段绑定(如「列表绑地图源、点击行定位地图」)。
在线演示
「源 → 图层」的最小组合:GeoJSON 源(3 个泵站点位,本身不渲染)+ 一个圆点图层
data-input: "source"引用它出图。更多交互示例见 GeoJSON 源。
GeoJSON 源 map-source-geojson
本地静态数据:粘贴 / 编辑 FeatureCollection 文本,或对话框随机生成。远程数据请用动态源。
关键配置:geojson-text(内联 FeatureCollection JSON)。
{ "type": "map-source-geojson", "uid": "src_geo", "enabled": true, "options": {
"geojson-text": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[116.4,39.9]},\"properties\":{\"name\":\"站点A\",\"value\":82}}]}",
"source-publish": true, "source-publish-name": "站点源" } }CAD 查询源 map-source-query
从 vjmap CAD 图按图层 / 范围 / 属性查询图形要素(coordinate-system: cad 时用)。
关键配置:query-condition(属性条件)、query-fields(返回字段)、query-limit(最多条数,默认 1000)、query-include-geom(返回几何)、query-bounds + query-is-contains(范围 / 是否包含);service-mode(inherit 继承本体 / custom 自填 service-url / service-token / mapid)。
{ "type": "map-source-query", "uid": "src_cad", "enabled": true, "options": {
"service-mode": "inherit", "query-condition": "", "query-limit": 2000, "query-include-geom": true } }动态数据 map-source-dynamic
远程 / 接口 / 实时数据,与工程「连接子系统」对接。
关键配置:
| option | 说明 |
|---|---|
req-type | 取数方式:GET / POST(HTTP)/ SOURCE(引用上游数据源)/ CONNECTION(引用工程连接) |
url / req-headers / req-body | HTTP 请求地址 / 头 / 参数 |
from-source-uid | SOURCE 时的上游源 |
from-connection-id + from-connection-table | CONNECTION 时的工程连接与表 |
interval | 轮询间隔(秒,0 = 不轮询) |
process-script | 处理脚本(对返回数据加工为要素 / 记录) |
use-mock + mock-data | 编辑态用 Mock 数据预览 |
{ "type": "map-source-dynamic", "uid": "src_api", "enabled": true, "options": {
"req-type": "GET", "url": "https://example.com/api/points", "interval": 10,
"process-script": "return data.list" } }图形绘制 map-source-draw
在地图上交互绘制点 / 线 / 面 → GeoJSON。
关键配置:draw-features(交互绘制产出的 GeoJSON,通常由编辑器绘制工具写入)。
{ "type": "map-source-draw", "uid": "src_draw", "enabled": true, "options": { "draw-features": "" } }CAD 绘制 map-source-mapcad
vjmapext MapCadLayer 自渲染的 CAD 标绘。
关键配置:cad-document(vjmapext MapCadLayer 文档)。
{ "type": "map-source-mapcad", "uid": "src_mapcad", "enabled": true, "options": { "cad-document": "" } }