| Name | Type | Description |
|---|---|---|
options |
GeoJsonPrimitiveConstructorOptions | optional |
Examples:
// Load GeoJSON
const loader = await Cesium.GeoJsonPrimitive.fromUrl("./data.geojson");
viewer.scene.primitives.add(loader);
// Access GeoJSON features and properties
loader.points; // BufferPointCollection | undefined
loader.polylines; // BufferPolylineCollection | undefined
loader.polygons; // BufferPolygonCollection | undefined
loader.ids; // source feature IDs
loader.properties; // source feature properties
// Style GeoJSON
const material = new Cesium.BufferPolylineMaterial({
color: Cesium.Color.RED,
width: 4,
});
const polyline = new Cesium.BufferPolyline();
const count = primitive.polylines.primitiveCount;
for (let i = 0; i < count; i++) {
primitive.polylines.get(i, polyline);
const properties = primitive.getProperties(polyline.featureId);
if (properties.myCustomProperty === true) {
polyline.setMaterial(material);
}
}
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
Members
Feature count represented by the loaded collections.
Lookup table from integer ID generated by GeoJsonPrimitive, to integer or string Feature ID from GeoJSON source.
readonly points : BufferPointCollection|undefined
Buffer point collection for point geometries.
readonly polygons : BufferPolygonCollection|undefined
Buffer polygon collection for polygon geometries.
readonly polylines : BufferPolylineCollection|undefined
Buffer polyline collection for linestring geometries.
Source GeoJSON properties, indexed by generated integer ID.
Loader source URL when created via
GeoJsonPrimitive.fromUrl.
Methods
static Cesium.GeoJsonPrimitive.fromGeoJson(geoJson, options) → GeoJsonPrimitive
Creates a loader directly from a parsed GeoJSON object.
| Name | Type | Description |
|---|---|---|
geoJson |
object | |
options |
GeoJsonPrimitiveConstructorOptions | optional |
Returns:
async static Cesium.GeoJsonPrimitive.fromUrl(url, options) → Promise.<GeoJsonPrimitive>
Loads GeoJSON from a URL or
Resource.
| Name | Type | Description |
|---|---|---|
url |
Resource | string | |
options |
GeoJsonPrimitiveConstructorOptions | optional |
Returns:
| Name | Type | Description |
|---|---|---|
featureId |
number |
| Name | Type | Description |
|---|---|---|
featureId |
number |
