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:
- 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.
- 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).
- 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.
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 viaMapViewRendereronto aGoogleMap, this value is passed directly toPolylineOptions.width(it.width)andPolygonOptions.strokeWidth(it.strokeWidth).Because the Google Maps Android SDK interprets
PolylineOptions.widthin raw physical screen pixels:xxhdpi3x,xxxhdpi3.5x/4x), lines with width values such as1.0or2.0render as hairline strokes (< 0.7 dp) that are difficult to see.GMSPolyline.strokeWidthin density-independent screen points (which automatically scale on Retina displays).<width>is omitted in KML,KmlMapperdefaults to1.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/orKmlMapper):MapViewRenderer(such asdensityAware: Boolean = false, taking a display density multiplier orDisplayMetrics) to scale stroke widths from dp/points to device screen pixels:strokeWidthTransformer: ((Float) -> Float)?allowing callers to customize width resolution.KmlMapperwhen<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 parsedDataScene/DataLayerfeatures prior to callingrenderer.render(scene)and adjust eachLineStyle.widthorPolygonStyle.strokeWidthby multiplying bycontext.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.