I'm trying to add ImageVector icons I have (created as, for example, Icons.Default.Home
) to Markers in Google Maps. What I currently have is this:
val opt = MarkerOptions()
opt.position(LatLng(lat, lng)) // lat and lng are defined above
opt.title(title) // title as well
opt.icon(BitmapDescriptorFactory.?????) // and there the problem occurs.
What I found out it that BitmapDescriptorFactory
can create the requested BitmapDescriptor
by passing a resource or a bitmap (respectively BitmapDescriptorFactory.fromResource(resourceId: Int)
and BitmapDescriptorFactory.fromBitmap(image: Bitmap)
).
The problem is I cannot find out how to convert the ImageVector I got from Icons.Default.Home
to any of the above. I found some questions on the Stack about converting a vector drawable to a bitmap, but still, none of them covers the problem with converting ImageVector. I also checked if the instance of ImageVector has any potentially helpful methods, but it can only - if I'm not mistaken - convert it to a String, which is totally useless in my case.
Any help will be highly appreciated