GeoJsonPrimitive

Lightweight GeoJSON loader that converts features directly into BufferPointCollection, BufferPolylineCollection, and BufferPolygonCollection. Unlike GeoJsonDataSource, this path does not create entities. Instead, it exposes high-throughput buffer primitive collections that can be added directly to Scene#primitives.

new Cesium.GeoJsonPrimitive(options)

Name Type Description
options GeoJsonPrimitiveConstructorOptions optional
Example:
const loader = await Cesium.GeoJsonPrimitive.fromUrl("./data.geojson");
viewer.scene.primitives.add(loader);

loader.points;     // BufferPointCollection | undefined
loader.polylines;  // BufferPolylineCollection | undefined
loader.polygons;   // BufferPolygonCollection | undefined
loader.ids;        // source feature IDs
loader.properties; // source feature properties
Experimental

This feature is not final and is subject to change without Cesium's standard deprecation policy.

Members

readonly featureCount : number

已加载集合所表示的特征数量。

readonly ids : Array.<(string|number|undefined)>

从 GeoJsonPrimitive 生成的整型 ID 到 GeoJSON 源中的整型或字符串 Feature ID 的查找表。
用于点几何的缓冲点集合。
用于多边形几何的缓冲多边形集合。
用于线几何(linestring)的缓冲折线集合。

readonly properties : Array.<Record.<string, unknown>>

源 GeoJSON 属性,按生成的整型 ID 索引。

readonly url : string|undefined

通过 GeoJsonPrimitive.fromUrl 创建时的加载器源 URL。

Methods

static Cesium.GeoJsonPrimitive.fromGeoJson(geoJson, options)GeoJsonPrimitive

直接从已解析的 GeoJSON 对象创建加载器。
Name Type Description
geoJson object
options GeoJsonPrimitiveConstructorOptions optional
Returns:

async static Cesium.GeoJsonPrimitive.fromUrl(url, options)Promise.<GeoJsonPrimitive>

从 URL 或 Resource 加载 GeoJSON。
Name Type Description
url Resource | string
options GeoJsonPrimitiveConstructorOptions optional
Returns:
Name Type Description
featureId number
Name Type Description
featureId number
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。