I am using MapBox 8.4.0
and I have the following snippet to load the map on a fragment, pinning the user's current location with a marker. I need to customize the marker by dynamically setting foregroundDrawable
with an image loaded from a network URL. But foregroundDrawable
only accepts a resource ID as parameter.
val customOptions = LocationComponentOptions.builder(context!!)
.elevation(5f)
.foregroundDrawable(R.drawable.icon_profile) // set image dynamically
.backgroundDrawable(R.drawable.icon_current_location)
.build()
val activationOptions = LocationComponentActivationOptions.builder(context!!, style)
.locationComponentOptions(customOptions)
.build()
mapboxMap.locationComponent.apply {
activateLocationComponent(activationOptions)
isLocationComponentEnabled = true
cameraMode = CameraMode.TRACKING
renderMode = RenderMode.NORMAL
}
It should look like this with the profile icon
replaced with the loaded image at run time.
https://i.stack.imgur.com/eoXuG.jpg
Any way I could achieve this?