简体   繁体   中英

How to rotate marker icon on google map api v2?

I have some pin graphic for my markers, but i have to rotate them. I googled alot but just coudnt find the solution.

Is there anybody know how could i achive this somehow ?

BitmapDescriptor does not have any functions like this, nor have MarkerOptions or Marker itself.

Please suggest me some ways.

In a new maps api (revision 7 of API v2) new method called setIcon (BitmapDescriptor icon) was added you can try it after update - it must work flawlessly. https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Marker#setIcon%28com.google.android.gms.maps.model.BitmapDescriptor%29

But if you don't want to update then the only way to do this is changing marker icon at runtime (dynamically) but as was said here https://developers.google.com/maps/documentation/android/marker : You can't change the icon once you've created the marker . So the only way is dynamically recreate marker.This is a bad solution because recreating markers takes a lot of memory allocation so it results in garbage collection and performance drawbacks. In order to avoid this create all your marker bitmaps and add all of them to the map at once. After that you can use Marker.setVisible(boolean) function to display the one that you currently need.

Have you tried marker.rotation(float value) ?

take a look at https://developers.google.com/maps/documentation/android/marker#flatten_a_marker

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