How to get Icon of Google Maps marker?

2.4k views Asked by At

With marker.getTitle() you get the title of a marker, but how can I ask for the icon? I want to ask if the icon of a marker is set to certain drawable and if so do something.

2

There are 2 answers

3
Adam Fręśko On

Well you can create marker with new MarkerOptions() Like this:

map.addMarker(new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.house_flag))
            .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left
            .position(new LatLng(41.889, -87.622)));

So you can simply store this data in some linked list or hash map

5
Pieter van der Vyver On

Without context on why you need the Icon, it is really hard to understand why you want it.

If you just want to move the marker or change the rotation you can do that by saving a variable for the Marker.

Marker allows .setPosition(LatLng) and .setRotation(Float).

Hope this helps someone since this is an old question