GeoJSONSource

GeoJSON 归一化静态工具。纯数据转换,不含渲染/坐标系逻辑,把各种 GeoJSON 输入 统一成内部要素列表,并按几何类型提取点/线/面。与图层解耦,可独立使用。

支持输入:FeatureCollection / Feature / Feature[] / 裸 Geometry; 支持几何:Point / MultiPoint / LineString / MultiLineString / Polygon / MultiPolygon。

构造函数

方法

  • 提取点集与权重(只认 Point / MultiPoint,其余几何忽略)

    参数类型说明
    featuresGeoJSONNormalizedFeature[]GeoJSONSource.normalize 的输出
    weightField 可选string权重字段名

    返回值 { points: number[][]; weights: number[] }

    points 为 [lng, lat] 数组,weights 为对应权重

    weightField 'count'
    
  • 归一化为统一的要素列表

    参数类型说明
    inputobject | any[]GeoJSON 输入(FeatureCollection / Feature / Feature[] / 裸 Geometry)
    idKey 可选string取 id 的 properties 字段名

    返回值 GeoJSONNormalizedFeature[]

    idKey 'id'
    

    示例代码1

    const features = BMap.GeoJSONSource.normalize({
    type: 'FeatureCollection',
    features: [
    { type: 'Feature', geometry: { type: 'Point', coordinates: [116.404, 39.915] }, properties: { id: 1 } }
    ]
    });