@@ -719,6 +719,7 @@ private fun MarkerImpl(
719719 * @param onInfoWindowClick a lambda invoked when the marker's info window is clicked
720720 * @param onInfoWindowClose a lambda invoked when the marker's info window is closed
721721 * @param onInfoWindowLongClick a lambda invoked when the marker's info window is long clicked
722+ * @param icon sets the icon for the marker
722723 * @param pinConfig the PinConfig object that will be used for the advanced marker
723724 * @param iconView the custom view to be used on the advanced marker
724725 * @param collisionBehavior the expected collision behavior
@@ -743,6 +744,7 @@ public fun AdvancedMarker(
743744 onInfoWindowClick : (Marker ) -> Unit = {},
744745 onInfoWindowClose : (Marker ) -> Unit = {},
745746 onInfoWindowLongClick : (Marker ) -> Unit = {},
747+ icon : BitmapDescriptor ? = null,
746748 pinConfig : PinConfig ? = null,
747749 iconView : View ? = null,
748750 collisionBehavior : Int = AdvancedMarkerOptions .CollisionBehavior .REQUIRED
@@ -765,6 +767,7 @@ public fun AdvancedMarker(
765767 onInfoWindowClick = onInfoWindowClick,
766768 onInfoWindowClose = onInfoWindowClose,
767769 onInfoWindowLongClick = onInfoWindowLongClick,
770+ icon = icon,
768771 pinConfig = pinConfig,
769772 iconView = iconView,
770773 collisionBehavior = collisionBehavior
@@ -797,6 +800,7 @@ public fun AdvancedMarker(
797800 * will be ignored.
798801 * @param infoContent optional composable lambda expression for customizing
799802 * the info window's content. If this value is non-null, [infoWindow] must be null.
803+ * @param icon sets the icon for the marker
800804 * @param pinConfig the PinConfig object that will be used for the advanced marker
801805 * @param iconView the custom view to be used on the advanced marker
802806 * @param collisionBehavior the expected collision behavior
@@ -823,6 +827,7 @@ private fun AdvancedMarkerImpl(
823827 onInfoWindowLongClick : (Marker ) -> Unit = {},
824828 infoWindow : (@Composable (Marker ) -> Unit )? = null,
825829 infoContent : (@Composable (Marker ) -> Unit )? = null,
830+ icon : BitmapDescriptor ? = null,
826831 pinConfig : PinConfig ? = null,
827832 iconView : View ? = null,
828833 collisionBehavior : Int = AdvancedMarkerOptions .CollisionBehavior .REQUIRED
@@ -836,10 +841,18 @@ private fun AdvancedMarkerImpl(
836841 val advancedMarkerOptions = AdvancedMarkerOptions ()
837842 .position(state.position)
838843 .collisionBehavior(collisionBehavior)
844+
845+ // Determine the icon for the marker in order of precedence:
846+ // 1. Use iconView if provided (takes full precedence and overrides all).
847+ // 2. If no iconView, use pinConfig to generate a BitmapDescriptor.
848+ // 3. If neither iconView nor pinConfig are available, fall back to the raw icon.
849+
839850 if (iconView != null ) {
840851 advancedMarkerOptions.iconView(iconView)
841852 } else if (pinConfig != null ) {
842853 advancedMarkerOptions.icon(BitmapDescriptorFactory .fromPinConfig(pinConfig))
854+ } else if (icon != null ) {
855+ advancedMarkerOptions.icon(icon)
843856 }
844857 advancedMarkerOptions.contentDescription(contentDescription)
845858 advancedMarkerOptions.alpha(alpha)
@@ -897,14 +910,19 @@ private fun AdvancedMarkerImpl(
897910 }
898911 }
899912 update(pinConfig) {
900- if (iconView == null ) {
913+ if (icon == null && iconView == null ) {
901914 this .marker.setIcon(pinConfig?.let { it1 ->
902915 BitmapDescriptorFactory .fromPinConfig(
903916 it1
904917 )
905918 })
906919 }
907920 }
921+ update(icon) {
922+ if (iconView == null ) {
923+ this .marker.setIcon(it)
924+ }
925+ }
908926
909927 update(visible) { this .marker.isVisible = it }
910928 update(zIndex) { this .marker.zIndex = it }
0 commit comments