provideRoadShieldIcon
fun provideRoadShieldIcon(reference: IconReference, content: String): Result<Bitmap, RoadShieldIconProviderFailure>
Generate a road shield image.
The reference
parameter is used to access an asset for the base road shield image, if no image can be found i.e., the reference is invalid, then a fallback image is generated.
The fallback image is a rounded rectangle with a white background and black text and border.
The navigation engine provides GuidanceInstruction
instances during navigation the road shield reference can be obtained from instruction's properties.
To generate the road shields the following code snippet can be used:
val roadShieldProvider = RoadShieldIconProvider(applicationContext)
val imageList = guidanceInstruction?.nextSignificantRoad?.shields?.map { roadShield ->
roadShieldIconProvider.provideRoadShieldIcon(
reference = IconReference(roadShield.reference),
content = roadShield.shieldContent,
).value().toAndroidBitmap()
}.orEmpty(),
Content copied to clipboard
Return
Result containing either a bitmap of the generated road shield image or a failure if the image could not be constructed.
Parameters
reference
The reference of the base road shield image.
content
The text to draw on the base road shield image.