Skip to content

GeoJsonLayer drops z-index when bridging legacy styles to the renderer model #1788

Description

@kikoso

Follow-up to #1785 / #1784.

#1785 added zIndex to the renderer model's PolygonStyle and applied it in MapViewRenderer.createPolygonOptions(). That works for callers who construct a PolygonStyle by hand, but nothing fills the new field from the GeoJSON path, and the point/line equivalents have no field at all.

The gap

The legacy GeoJson*Style classes have supported z-index for a long time. Each wraps a MarkerOptions/PolylineOptions/PolygonOptions and exposes getZIndex()/setZIndex():

  • GeoJsonPointStyle.getZIndex() (GeoJsonPointStyle.kt:112)
  • GeoJsonLineStringStyle.getZIndex() (GeoJsonLineStringStyle.kt:61)
  • GeoJsonPolygonStyle.getZIndex() (GeoJsonPolygonStyle.kt:74)

GeoJsonLayer.toModelFeature() bridges those legacy styles into the renderer model, and drops z-index in every case:

Legacy style Model counterpart Status
GeoJsonPolygonStyle PolygonStyle.zIndex (added in #1785) field exists, not passed (GeoJsonLayer.kt:312, :323)
GeoJsonLineStringStyle LineStyle no zIndex field
GeoJsonPointStyle PointStyle no zIndex field

So this silently does nothing when the layer is rendered through MapViewRenderer:

val style = GeoJsonPolygonStyle().apply { setZIndex(10f) }
feature.polygonStyle = style   // z-index lost on the way to PolygonOptions

This is a behavior regression relative to the legacy renderer, which called toPolygonOptions() on the style object directly and therefore kept the z-index.

Proposed fix

  1. Add zIndex: Float = 0.0f to the model PointStyle and LineStyle, mirroring the property feat: add polygon z-index support to PolygonStyle/MapViewRenderer #1785 added to PolygonStyle. Additive and backward compatible.
  2. Apply it in MapViewRenderer.createMarkerOptions(), createAdvancedMarkerOptions() and createPolylineOptions(), mirroring createPolygonOptions().
  3. Pass getZIndex() through all four legacy-bridge sites in GeoJsonLayer.toModelFeature().

Out of scope

  • KML. <drawOrder> is an Overlay element in the KML 2.2 spec, not a Placemark one, so there is no placemark-level z-index to map. The parser models it only on GroundOverlay (KmlModel.kt:90) and KmlMapper already maps it to GroundOverlayStyle.zIndex. Nothing to do.
  • KmlLayer.kt:409 has the same bridge shape, but legacy KmlStyle never writes a polygon z-index, so it is always 0, a no-op.
  • GeoJsonMapper, which parses raw simplestyle-spec properties. That spec has no z-index key.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions