Skip to content

fix(data): apply StyleMap styles and fix four KML and GeoJSON style bugs - #1809

Merged
dkhawk merged 1 commit into
test/data-styles-and-parsersfrom
fix/data-kml-geojson-bugs
Oct 1, 2026
Merged

dkhawk merged 1 commit into
test/data-styles-and-parsersfrom
fix/data-kml-geojson-bugs

Conversation

@kikoso

@kikoso kikoso commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the five bugs documented by the tests in #1808. Stacked on #1808; GitHub will retarget this to main once that merges. Each fix removes the matching @Ignore, so the tests that documented the bugs are now the regression tests.

  1. StyleMap styles are applied. KmlLayer resolved a placemark's StyleMap to the normal styleUrl with its leading # ("#red"), but shared styles are keyed by bare id ("red"), so placemarks styled through a StyleMap were unstyled. Google Earth exports put a StyleMap on almost every placemark. getStyleIdFromMap still returns the URL as written ("#red").
  2. No crash on a shared <Style> or <StyleMap> without an id. They are skipped, since nothing can reference them.
  3. No crash on a <GroundOverlay> without a <LatLonBox> (for example gx:LatLonQuad, which Google Earth writes for rotated overlays). The overlay is skipped with a log warning; drawing the quad's bounding box would show a rotated image unrotated and stretched.
  4. GeoJsonLineStringStyle.toPolylineOptions keeps the pattern and caps. Inside PolylineOptions().apply { }, the unqualified getPattern() and cap getters resolved to the new options instead of the style.
  5. KmlStyle random icon color mode randomizes the color, not the hue. It passed the hue (0 to 360) to computeRandomColor, which expects ARGB, so a green marker turned blue. The style now keeps the marker's ARGB color (KML's default white when none is set).

Bugs 2 and 3 are reachable with user-supplied KML.

Testing

./gradlew :data:testDebugUnitTest :data:apiCheck :data:lintDebug: 187 tests, 0 failures, 0 skipped (the five previously ignored tests now pass). The public API is unchanged.

BEGIN_COMMIT_OVERRIDE
fix(data): apply styles referenced through a KML StyleMap
fix(data): do not crash on a KML Style or StyleMap without an id
fix(data): do not crash on a KML GroundOverlay without a LatLonBox
fix(data): keep the pattern and caps in GeoJsonLineStringStyle.toPolylineOptions
fix(data): randomize the marker color, not its hue, in KML random icon color mode
END_COMMIT_OVERRIDE

- KmlLayer resolved StyleMap entries with their leading '#' while shared
  styles are keyed by bare id, so placemarks styled through a StyleMap
  were unstyled.
- KmlLayer no longer throws on a shared Style or StyleMap without an id;
  they are skipped since nothing can reference them.
- KmlLayer no longer throws on a GroundOverlay without a LatLonBox (for
  example gx:LatLonQuad); the overlay is skipped with a warning.
- GeoJsonLineStringStyle.toPolylineOptions now keeps the pattern and the
  start and end caps.
- KmlStyle random icon color mode now randomizes the marker color
  instead of its hue, so markers keep their color family.

The regression tests from the data coverage tests are no longer ignored.
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 60.59% -0.1% 🍏
Files changed 79.21% 🍏

Module Coverage
Kover Gradle Plugin XML report for :data 61.36% -0.2% 🍏
Files
Module File Coverage
Kover Gradle Plugin XML report for :data GeoJsonLineStringStyle.kt 100% 🍏
KmlStyle.kt 98.4% 🍏
KmlLayer.kt 62.45% -1.82% 🍏

@kikoso
kikoso marked this pull request as ready for review October 1, 2026 17:29
@dkhawk
dkhawk merged commit 4ae5ad9 into test/data-styles-and-parsers Oct 1, 2026
5 checks passed
@dkhawk
dkhawk deleted the fix/data-kml-geojson-bugs branch October 1, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants