简体   繁体   中英

How to get Icon of Google Maps marker?

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM