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)

参数名称 类型 描述信息
options GeoJsonPrimitiveConstructorOptions 可选
使用示例:
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.

成员(属性)

readonly featureCount : number

Feature count represented by the loaded collections.

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

Lookup table from integer ID generated by GeoJsonPrimitive, to integer or string Feature ID from GeoJSON source.
Buffer point collection for point geometries.
Buffer polygon collection for polygon geometries.
Buffer polyline collection for linestring geometries.

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

Source GeoJSON properties, indexed by generated integer ID.

readonly url : string|undefined

Loader source URL when created via GeoJsonPrimitive.fromUrl.

方法

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

Creates a loader directly from a parsed GeoJSON object.
参数名称 类型 描述信息
geoJson object
options GeoJsonPrimitiveConstructorOptions 可选
返回值:

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

Loads GeoJSON from a URL or Resource.
参数名称 类型 描述信息
url Resource | string
options GeoJsonPrimitiveConstructorOptions 可选
返回值:
参数名称 类型 描述信息
featureId number
参数名称 类型 描述信息
featureId number