Skip to content

feat(data): add density-aware / dp-scaling option for stroke width in MapViewRenderer #1793

Open

Description

@dkhawk

Is your feature request related to a problem? Please describe.
In KML (and GeoJSON) files, line stroke width is specified as a numerical value (<LineStyle><width> is defined as "width in pixels" per OGC KML 2.2 §12.8). When rendered via MapViewRenderer onto a GoogleMap, this value is passed directly to PolylineOptions.width(it.width) and PolygonOptions.strokeWidth(it.strokeWidth).

Because the Google Maps Android SDK interprets PolylineOptions.width in raw physical screen pixels:

  1. On modern high-density Android devices (e.g., xxhdpi 3x, xxxhdpi 3.5x/4x), lines with width values such as 1.0 or 2.0 render as hairline strokes (< 0.7 dp) that are difficult to see.
  2. Cross-platform rendering diverges significantly from iOS, where the Google Maps iOS SDK defines GMSPolyline.strokeWidth in density-independent screen points (which automatically scale on Retina displays).
  3. When <width> is omitted in KML, KmlMapper defaults to 1.0f, resulting in a single physical pixel line on high-DPI screens.

This was previously reported in #1401 against the legacy KmlLayer.

Describe the solution you'd like
Provide an opt-in density-scaling mechanism or transform hook in MapViewRenderer (and/or KmlMapper):

  • For example, an opt-in property on MapViewRenderer (such as densityAware: Boolean = false, taking a display density multiplier or DisplayMetrics) to scale stroke widths from dp/points to device screen pixels:
    val effectiveWidth = if (densityAware) style.width * displayDensity else style.width
  • Or a customizable strokeWidthTransformer: ((Float) -> Float)? allowing callers to customize width resolution.
  • Additionally, consider revising the default fallback width in KmlMapper when <width> is null/omitted so it doesn't default to a 1px hairline.

Describe alternatives you've considered
With the new com.google.maps.android.data.renderer.* architecture, developers can iterate over the parsed DataScene / DataLayer features prior to calling renderer.render(scene) and adjust each LineStyle.width or PolygonStyle.strokeWidth by multiplying by context.resources.displayMetrics.density. However, built-in support or an opt-in property in the renderer would streamline cross-platform parity and developer ergonomics.

Additional context
Spun off from discussion in #1401.

Activity

  1. added
    type: feature request
    triage me
    on Sep 23, 2026
  2. self-assigned this
    on Sep 23, 2026
  3. added
    priority: p2
    and removed
    triage me
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p2type: feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions