CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.94k stars 3.49k forks source link

`KMLDataSource` should allow customization of default styles similar to `GeoJsonDataSource` #9277

Open thw0rted opened 3 years ago

thw0rted commented 3 years ago

The load method for GeoJsonDataSource takes a number of options that related to style defaults -- marker size, color, and symbol, stroke and fill options, etc. The current implementation for KML hard codes a lot of this and doesn't expose any way to override them -- the code has nine instances of the string Color.WHITE, for example, and billboards are built around a constant called BILLBOARD_SIZE that can't be modified. Technically, these properties can be modified after the fact by altering entities in the collection, but only by taking some liberties guessing what might have been derived from a default instead of specified in the source document. (My current workaround actually grabs the private _pinBuilder, because the only way to tell if the billboard is a default is to do an equality-comparison against the cached canvas!)

The original code wasn't really written with customization in mind (and is over 4k LOC in a single file!) so I haven't taken a crack at this myself yet. My fast-and-lose workaround lets me apply some customizations in a way that works well enough, for me, for now, but if anybody ever gets around to refactoring it, I'd like for them to keep this in mind.

thw0rted commented 3 years ago

Trackback to this suggestion I made in Community. If this feature gets added, it might be a good time to rethink what the default-default (as opposed to overridden-default) styles are for KML.