GeoJSONSource
构造函数
返回值 GeoJSONSource
方法
- #extractPoints(
features: GeoJSONNormalizedFeature[],
weightField?: string,
): { points: number[][]; weights: number[] }提取点集与权重(只认
Point/MultiPoint,其余几何忽略)参数 类型 说明 featuresGeoJSONNormalizedFeature[]GeoJSONSource.normalize 的输出 weightField可选string权重字段名 返回值 { points: number[][]; weights: number[] }
points为 [lng, lat] 数组,weights为对应权重Default
weightField 'count'
归一化为统一的要素列表
参数 类型 说明 inputobject | any[]GeoJSON 输入( FeatureCollection/Feature/Feature[]/ 裸 Geometry)idKey可选string取 id 的 properties 字段名 返回值 GeoJSONNormalizedFeature[]
Default
idKey 'id'示例代码1
const features = BMap.GeoJSONSource.normalize({
type: 'FeatureCollection',
features: [
{ type: 'Feature', geometry: { type: 'Point', coordinates: [116.404, 39.915] }, properties: { id: 1 } }
]
});
提取线串集合,统一为多条线
[[[lng, lat], ...], ...]。Polygon/MultiPolygon的环也会作为闭合线返回参数 类型 说明 featureGeoJSONNormalizedFeatureGeoJSONSource.normalize 输出的单个要素 返回值 number[][][]
提取多边形集合,统一为
[[outer, hole1, ...], ...](每个多边形含外环与洞)参数 类型 说明 featureGeoJSONNormalizedFeatureGeoJSONSource.normalize 输出的单个要素 返回值 number[][][][]
GeoJSON 归一化静态工具。纯数据转换,不含渲染/坐标系逻辑,把各种 GeoJSON 输入 统一成内部要素列表,并按几何类型提取点/线/面。与图层解耦,可独立使用。
支持输入:
FeatureCollection/Feature/Feature[]/ 裸 Geometry; 支持几何:Point/MultiPoint/LineString/MultiLineString/Polygon/MultiPolygon。