If you are using vector drawable
use this extension:
fun Context.bitmapDescriptorFromVector(vectorResId:Int): BitmapDescriptor {
val vectorDrawable = ContextCompat.getDrawable(this, vectorResId)
vectorDrawable!!.setBounds(0, 0, vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight)
val bitmap = Bitmap.createBitmap(vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
vectorDrawable.draw(Canvas(bitmap))
return BitmapDescriptorFactory.fromBitmap(bitmap)
}
And set to the marker icon:
val markerOptions = MarkerOptions().position(latLng)
.title("Current Location")
.snippet("Thinking of finding some thing...")
.icon(bitmapDescriptorFromVector("Your icon resource id"))// call extension here
mMarker = googleMap.addMarker(markerOptions)
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.current_position_tennis_ball)
and then op.icon(icon); – Jumper