Repository navigation
Description
Summary
A KML <GroundOverlay> without <Icon> crashes when the KML is rendered through the new DataLayer path (DataLayerLoader or Kml.toLayer()). MapViewRenderer adds the overlay without any image, and the Maps SDK does not accept it.
Expected behavior
The overlay is skipped (or added hidden with the transparent placeholder, as we do already while an icon is loading), and the rest of the KML renders.
Observed behavior
KmlMapper maps the missing href to iconUrl = null, so MapViewRenderer goes into the "No iconUrl, add directly" branch and calls addGroundOverlay(options) without image(...):
Lines 265 to 270 in 83a75c7
| } ?: run { | |
| // No iconUrl, add directly | |
| val mapOverlay = groundOverlayCollection?.addGroundOverlay(options) ?: map.addGroundOverlay(options) | |
| if (mapOverlay != null) { | |
| mapObjects.add(mapOverlay) | |
| } |
I tried addGroundOverlay with options without image on a Pixel 4 and the SDK throws:
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.dynamic.IObjectWrapper com.google.android.gms.maps.model.BitmapDescriptor.zza()' on a null object reference
The legacy KmlLayer is not affected: it maps the missing href to "", so it falls in the placeholder branch.
Environment details
- Pixel 4
- Android 13
- android-maps-utils
main(7.0.1)
Steps to reproduce
- Load a KML like the one below with
DataLayerLoader.loadInputStream(...)and render the resultingDataLayeron a map. - The renderer reaches the branch linked above and the SDK throws when the ground overlay is added.
Code example
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<GroundOverlay>
<name>Campus Overlay</name>
<LatLonBox>
<north>37.425</north>
<south>37.420</south>
<east>-122.080</east>
<west>-122.088</west>
</LatLonBox>
</GroundOverlay>
</Document>
</kml>I found it while reviewing #1858: the test fixture there has the same shape, and it passes only because the fake map in the testing toolkit accepts options without image.
Activity