Skip to content

Commit 9fda7ab

Browse files
authored
Merge pull request #13712 from CesiumGS/donmccurdy/docs/geojsonprimitive-examples
GeoJsonPrimitive: Add usage examples in API docs
2 parents 87f460f + c973533 commit 9fda7ab

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/engine/Source/Scene/GeoJsonPrimitive.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,36 @@ import BufferPolylineCollection from "./BufferPolylineCollection.js";
4141
* added directly to {@link Scene#primitives}.
4242
*
4343
* @example
44+
* // Load GeoJSON
4445
* const loader = await Cesium.GeoJsonPrimitive.fromUrl("./data.geojson");
4546
* viewer.scene.primitives.add(loader);
4647
*
48+
* @example
49+
* // Access GeoJSON features and properties
4750
* loader.points; // BufferPointCollection | undefined
4851
* loader.polylines; // BufferPolylineCollection | undefined
4952
* loader.polygons; // BufferPolygonCollection | undefined
5053
* loader.ids; // source feature IDs
5154
* loader.properties; // source feature properties
55+
*
56+
* @example
57+
* // Style GeoJSON
58+
* const material = new Cesium.BufferPolylineMaterial({
59+
* color: Cesium.Color.RED,
60+
* width: 4,
61+
* });
62+
*
63+
* const polyline = new Cesium.BufferPolyline();
64+
* const count = primitive.polylines.primitiveCount;
65+
* for (let i = 0; i < count; i++) {
66+
* primitive.polylines.get(i, polyline);
67+
*
68+
* const properties = primitive.getProperties(polyline.featureId);
69+
* if (properties.myCustomProperty === true) {
70+
* polyline.setMaterial(material);
71+
* }
72+
* }
73+
*
5274
* @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
5375
*/
5476
class GeoJsonPrimitive {

0 commit comments

Comments
 (0)