一键导入
minemap-kml-source
MineMap KML 数据源。用于加载 KML / KMZ 文件,解析 LineStyle / IconStyle / LabelStyle / PolyStyle 等样式继承,并把 KML 属性映射为 line / circle / fill / symbol 派生图层。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
MineMap KML 数据源。用于加载 KML / KMZ 文件,解析 LineStyle / IconStyle / LabelStyle / PolyStyle 等样式继承,并把 KML 属性映射为 line / circle / fill / symbol 派生图层。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
MineMap 3D 公告板(Billboard)专题。覆盖 BillboardMaterial / BillboardGeometry / BillboardInstance 动画、拾取高亮、动态纹理更新与轨迹对象联动;不与 DOM 覆盖物 Marker 混淆。
MineMap 云与大气渲染链。用于启用体积云(多层 CloudLayer)、单片实例化云(map.cloudCollection)、大气散射与太阳 / 天空辐照度,重点说明主分支公开参数与禁用字段。
MineMap 事件订阅模型、图层事件代理、once/off 管理、矢量与三维对象拾取。
MineMap 热力图(heatmap)专题。用于二维 / 三维热力图、贴地热力、聚合权重、热力色阶与 3D 显示模式,重点说明 paint/layout 参数边界与典型失败场景。
MineMap 材质与着色规范。覆盖 `StandardMaterial`、`PhongMaterial`、`PhysicalMaterial`、`LambertMaterial`、`PolylineMaterial` 等主流材质的选型与调参。
MineMap 渲染后端(auto/webgpu/webgl2/webgl1)选择、降级策略、特效开关与性能调优。
| name | minemap-kml-source |
| description | MineMap KML 数据源。用于加载 KML / KMZ 文件,解析 LineStyle / IconStyle / LabelStyle / PolyStyle 等样式继承,并把 KML 属性映射为 line / circle / fill / symbol 派生图层。 |
KML(Keyhole Markup Language)是 OGC 标准的地理标记格式,常用于地铁线路、POI 集合、行政区标注等。
MineMap 4.25 公开支持把 KML 文件直接作为 geojson-style source:
DOMParser,因此也支持 WorkerLineStyle / IconStyle / LabelStyle / PolyStyle 映射到 feature propertiesIconStyle 里的图片资源会自动 addImage 进 sprite,引用名是 icon-id入口:
map.addSource("kml", {
type: "kml",
data: "../data/your.kml",
maxzoom: 16
});
map.on("load", () => {
map.addSource("kml-subway", {
type: "kml",
data: "../data/kml/2015beijingsubway.kml",
maxzoom: 16
});
// LineString ← KML LineStyle
map.addLayer({
id: "kml-line",
type: "line",
source: "kml-subway",
filter: ["==", "$type", "LineString"],
paint: {
"line-color": ["get", "stroke"],
"line-width": ["get", "stroke-width"],
"line-opacity": ["get", "stroke-opacity"]
}
});
// Point 有 icon 时 ← KML IconStyle(图片已自动 addImage)
map.addLayer({
id: "kml-icon",
type: "symbol",
source: "kml-subway",
filter: ["all", ["==", "$type", "Point"], ["has", "icon-id"]],
layout: {
"icon-image": ["get", "icon-id"],
"icon-size": ["get", "icon-scale"],
"icon-allow-overlap": true
}
});
// Polygon ← KML PolyStyle
map.addLayer({
id: "kml-fill",
type: "fill",
source: "kml-subway",
filter: ["==", "$type", "Polygon"],
paint: {
"fill-color": ["get", "fill"],
"fill-opacity": ["get", "fill-opacity"]
}
});
});
$type 区分几何:
LineStringPolygonPointget 表达式即可| KML 字段 | properties key | 说明 |
|---|---|---|
LineStyle.color | stroke | 十六进制颜色 |
LineStyle.width | stroke-width | 像素 |
LineStyle.color.a | stroke-opacity | 0..1 |
PolyStyle.color | fill | 十六进制颜色 |
PolyStyle.color.a | fill-opacity | 0..1 |
IconStyle.Icon.href | 自动 addImage + icon-id | 引擎自动注册到 sprite |
IconStyle.scale | icon-scale | 图标缩放 |
LabelStyle.color | text-color | 文字颜色 |
LabelStyle.color.a | text-opacity | 0..1 |
LabelStyle.scale | text-size | 文字大小 |
Placemark.name | name | 一般用于 text-field |
对应 demo:demo/html/KMLSource.html
// 线
map.addLayer({
id: "kml-subway-line",
type: "line",
source: "kml-subway",
filter: ["==", "$type", "LineString"],
paint: {
"line-color": ["get", "stroke"],
"line-width": ["get", "stroke-width"],
"line-opacity": ["get", "stroke-opacity"]
}
});
// 站点(带图标)
map.addLayer({
id: "kml-subway-icon",
type: "symbol",
source: "kml-subway",
filter: ["all", ["==", "$type", "Point"], ["has", "icon-id"]],
layout: {
"icon-image": ["get", "icon-id"],
"icon-size": ["get", "icon-scale"],
"icon-allow-overlap": true
}
});
// 站名
map.addLayer({
id: "kml-subway-label",
type: "symbol",
source: "kml-subway",
filter: ["==", "$type", "Point"],
layout: {
"text-field": ["get", "name"],
"text-anchor": "top",
"text-allow-overlap": false,
"text-size": ["get", "text-size"]
},
minzoom: 11
});
KML 里的 icon 图片会异步注册到 sprite,可以监听 kmlIconsLoaded 事件:
map.getSource("kml-subway").on("kmlIconsLoaded", (e) => {
console.log(
"registered icons:",
e.icons.map((i) => i.id)
);
});
queryRenderedFeaturesKML 解析后与 GeoJSON 行为一致,可以直接用 queryRenderedFeatures 做交互:
map.on("click", (e) => {
const features = map.queryRenderedFeatures(e.point, {
layers: ["kml-subway-line", "kml-subway-icon"]
});
if (features.length) {
console.log(features[0].properties);
}
});
不要写 addLayer({ type: 'kml' })。必须 addSource({ type: 'kml' }) + addLayer 用 line / symbol / fill / circle 派生。
kmlIconsLoadedKML 里的 IconStyle.Icon.href 是异步下载并 addImage 的,不要在 KML 加载完立刻假设 sprite 已经有这个 id。要么监听 kmlIconsLoaded,要么用 has-image filter 兜底。
data 必须是可访问的 URLdata 字段接受字符串 URL;目前 KML source 不会把内嵌 KML 字符串直接解析,需要先把 KML 写成本地 / 远端文件。
例如 stroke-width 直接来自 KML <width> 节点(KML 默认单位是像素),不需要二次换算。
kmlIconsLoaded;或 KML 里的 IconStyle.Icon.href 指向了不可访问的 URLLineStyle,properties 里 stroke 为空,给 paint 加 fallback 默认值fill-opacity 是否被 KML PolyStyle.color 里的 alpha 覆盖text-field 拿不到 name → KML 中 Placemark 没有 <name> 节点,或 styleUrl 引用了未定义的 Styleminemap-style-and-dataminemap-layer-systemminemap-events-and-picking