Google explains how to add markers, they recommend to add them using AdvancedMarker now:
#drawing-on-a-map
GoogleMap(
googleMapOptionsFactory = {
GoogleMapOptions().mapId("DEMO_MAP_ID")
},
//...
) {
AdvancedMarker(
state = MarkerState(position = LatLng(-34, 151)),
title = "Marker in Sydney"
)
AdvancedMarker(
state = MarkerState(position = LatLng(35.66, 139.6)),
title = "Marker in Tokyo"
)
}
The problem is that they don't tell how to change the icon of the AdvancedMarker anywhere in their documentation.
How can I do it? I need to specify a image stored in drawables resource folder.
Google explains how to add markers, they recommend to add them using AdvancedMarker now:
https://github.com/googlemaps/android-maps-compose?tab=readme-ov-file#drawing-on-a-map
GoogleMap(
googleMapOptionsFactory = {
GoogleMapOptions().mapId("DEMO_MAP_ID")
},
//...
) {
AdvancedMarker(
state = MarkerState(position = LatLng(-34, 151)),
title = "Marker in Sydney"
)
AdvancedMarker(
state = MarkerState(position = LatLng(35.66, 139.6)),
title = "Marker in Tokyo"
)
}
The problem is that they don't tell how to change the icon of the AdvancedMarker anywhere in their documentation.
How can I do it? I need to specify a image stored in drawables resource folder.
Share Improve this question edited 2 days ago halfer 20.4k19 gold badges108 silver badges201 bronze badges asked Feb 6 at 19:23 NullPointerExceptionNullPointerException 37.6k80 gold badges230 silver badges402 bronze badges1 Answer
Reset to default 0You can set a drawable resource using a Image
and set this image view to the MarkerComposable
.
GoogleMap() {
MarkerComposable(
state = marker3State,
onClick = markerClick,
) {
// Customize its content here as your needs
Column(Modifier.padding(10.dp)) {
Text(
text = "Marker 3",
color = androidx.compose.ui.graphics.Color.Black
)
Image(
painter = painterResource(R.drawable.ic_action_name),
contentDescription = ""
)
}
}
}
For more details, please go through the documentation of MarkerComposable
.