CesiumGS / CesiumGS/cesium

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

Open
#9,277 1 comment 1 reaction 0 assignees View on GitHub
category - data sources type - enhancement
Dominant language
JavaScript
Stars
15.8k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

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](https://github.com/CesiumGS/cesium/blob/master/Source/DataSources/KmlDataSource.js) 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.

Contributor guide

Open the contributing guide

Research direction

Start with Source/DataSources/KmlDataSource.js and compare its load behavior with GeoJsonDataSource's style options. Define the customization scope and API for KML defaults, including Color.WHITE and BILLBOARD_SIZE, then add coverage showing defaults can be overridden without replacing styles explicitly specified in the KML document.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.