| Name | Type | Description |
|---|---|---|
options |
GeoJsonPrimitiveConstructorOptions | optional |
Examples:
// 加载 GeoJSON
const loader = await Cesium.GeoJsonPrimitive.fromUrl("./data.geojson");
viewer.scene.primitives.add(loader);
// 访问 GeoJSON 特征和属性
loader.points; // BufferPointCollection | undefined
loader.polylines; // BufferPolylineCollection | undefined
loader.polygons; // BufferPolygonCollection | undefined
loader.ids; // 源特征 ID
loader.properties; // 源特征属性
// 设置 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 该特征尚未最终确定,可能根据 Cesium 的标准弃用政策发生变化。
Members
加载集合所代表的特征数量。
由 GeoJsonPrimitive 生成的整数 ID 到 GeoJSON 源中的整数或字符串特征 ID 的映射表。
readonly points : BufferPointCollection|undefined
点几何数据的缓冲点集合。
readonly polygons : BufferPolygonCollection|undefined
多边形几何数据的缓冲多边形集合。
readonly polylines : BufferPolylineCollection|undefined
线状几何数据的缓冲多线集合。
按生成的整数 ID 索引的源 GeoJSON 属性。
通过
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 |
