Can someone explain how to change marker icon with kotlin

Been trying to change marker icon on the map with kotlin. but it always not able to use the Drawable resource. always says that it is expecting ICON but I gave drawable !! and I have no other choice than sending Drawable to it !!

If you have a typical image file (png for example) in your drawable folder, you can use Icon.Factory.fromResources function:


If your image is defined as an android vector drawable, you can create a BitmapDrawable from it and use it inside Icon.Factory.fromDrawable function:

val drawable = this.resources.getDrawable(R.drawable.marker, theme)

val bitmap = Bitmap.createBitmap(

val canvas = Canvas(bitmap)
drawable.setBounds(0, 0, canvas.width, canvas.height)

val bitmapDrawable = BitmapDrawable(this.resources, bitmap)

    .icon(Icon.Factory.fromDrawable("name", bitmapDrawable)))
1 Like