You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kml Style width for LineString is not rendered in pixels #1401
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Kml Style width for LineString is not rendered in pixels
Expected behavior
The KML style width in float needs to be converted to pixels while rendering map.
Observed behavior
The KML style width is very thin on the map and there is a difference between 10dp width line and 10.0 as strokline width. The rendering of the same KML file line strings on google maps on Android is different from the thickness of the line strings on iOS.We also observed that the kml file without width element appears too thick on Android and very thin on iOS.
Environment details
All android versions and all device model
Google maps utility version "com.google.maps.android:android-maps-utils:3.8.2")
Steps to reproduce
Render any kml that has this style element and apply to line strings:
<Style>
9aB10FDA
10.0
</Style>
Code example
val kmlLayer = KmlLayer(
googleMap,
replaceWidthValue(ByteArrayInputStream(kmlByteArray)),
this
)
kmlLayer?.addLayerToMap()
I am unable to override the style using this kmlLayer object as the KmlStyle is not exposed. Please help to fix this as the rendering is not uniform on iOS and Android. Kindly provide us with as solution or workaround quickly if possible.
Hi @AiswaryaS, thank you for the report and patience! Here is an update on the status of this issue and how it is handled in the library:
1. Legacy KmlLayer Deprecation
In android-maps-utils v5.0+ (the modular Kotlin rewrite), KmlLayer and the legacy com.google.maps.android.data.kml.* package have been formally deprecated (@Deprecated("Use the new platform-agnostic data layer and renderer instead.")). Future development is centered on the new modular data rendering pipeline under com.google.maps.android.data.renderer.* (MapViewRenderer).
2. Technical Context: Android vs iOS Stroke Width
OGC KML 2.2 Specification (§12.8 <LineStyle>): Defines <width> strictly as "Width of the line, in pixels."
Google Maps Android SDK:PolylineOptions.width(float) accepts values in physical screen pixels, not density-independent pixels (dp).
Google Maps iOS SDK:GMSPolyline.strokeWidth is measured in screen points (which automatically scale by 2x or 3x on Retina displays).
Because the Android Maps SDK applies width directly in physical screen pixels, a KML <width>2</width> renders as a literal 2-pixel stroke. On modern high-density Android displays (xxhdpi / xxxhdpi), 2 physical device pixels is less than 0.7 dp, making it appear hairline-thin compared to iOS.
3. Programmatic Style Customization in the New Architecture
In the legacy KmlLayer, placemark styles were encapsulated internally and difficult to alter dynamically. In the new architecture:
KmlParser and KmlMapper parse KML into an open, platform-agnostic DataScene / DataLayer model with accessible Feature and LineStyle objects.
Callers can now inspect and adjust styles programmatically (such as scaling width by context.resources.displayMetrics.density) prior to rendering:
val kml =KmlParser.parse(inputStream)
val scene =KmlMapper.toScene(kml)
val density = context.resources.displayMetrics.density
// Programmatically adjust or scale line widths as needed
scene.layers.forEach { layer ->
layer.features.forEach { feature ->
(feature.style as?LineStyle)?.let { lineStyle ->// Adjust or scale width
}
}
}
val renderer =MapViewRenderer(googleMap, DefaultIconProvider(context))
renderer.render(scene)
4. Feature Request for Built-In Density Scaling
To track adding built-in, opt-in density awareness to MapViewRenderer (and reviewing fallback defaults when <width> is omitted in KML), we have opened a dedicated feature request: #1793.
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
kikoso commentedon May 6, 2025
Hi @AiswaryaS . I am not sure if I am following everything but the current KmlParser is indeed parsing the KmlStyle object, isn't it?
dkhawk commentedon Sep 23, 2026
Hi @AiswaryaS, thank you for the report and patience! Here is an update on the status of this issue and how it is handled in the library:
1. Legacy
KmlLayerDeprecationIn
android-maps-utilsv5.0+ (the modular Kotlin rewrite),KmlLayerand the legacycom.google.maps.android.data.kml.*package have been formally deprecated (@Deprecated("Use the new platform-agnostic data layer and renderer instead.")). Future development is centered on the new modular data rendering pipeline undercom.google.maps.android.data.renderer.*(MapViewRenderer).2. Technical Context: Android vs iOS Stroke Width
<LineStyle>): Defines<width>strictly as "Width of the line, in pixels."PolylineOptions.width(float)accepts values in physical screen pixels, not density-independent pixels (dp).GMSPolyline.strokeWidthis measured in screen points (which automatically scale by 2x or 3x on Retina displays).Because the Android Maps SDK applies width directly in physical screen pixels, a KML
<width>2</width>renders as a literal 2-pixel stroke. On modern high-density Android displays (xxhdpi/xxxhdpi), 2 physical device pixels is less than 0.7 dp, making it appear hairline-thin compared to iOS.3. Programmatic Style Customization in the New Architecture
In the legacy
KmlLayer, placemark styles were encapsulated internally and difficult to alter dynamically. In the new architecture:KmlParserandKmlMapperparse KML into an open, platform-agnosticDataScene/DataLayermodel with accessibleFeatureandLineStyleobjects.context.resources.displayMetrics.density) prior to rendering:4. Feature Request for Built-In Density Scaling
To track adding built-in, opt-in density awareness to
MapViewRenderer(and reviewing fallback defaults when<width>is omitted in KML), we have opened a dedicated feature request: #1793.