Maps V2 how to rotate Marker - where is rotation o

2020-03-29 02:59发布

问题:

According to all the docs I have, such as... this link

"rotation" is a valid marker option. But it's not there!

For instance if you put this code cited in the docs into your program ...

static final LatLng PERTH = new LatLng(-31.90, 115.86);
Marker perth = mMap.addMarker(new MarkerOptions()
                          .position(PERTH)
                          .anchor(0.5,0.5)
                          .rotation(90.0));

the rotation is flagged as not being a valid MarkerOption.

I also tried doing setRotation(float) on a returned Marker object to that got flagged as invalid too.

So, are the docs bad? Am I doing something wrong? How can I rotate the Marker?? Thanks, Gary

回答1:

So, are the docs bad?

No, the docs are perfectly fine, at least with respect to this.

Am I doing something wrong?

You do not have the latest Play Services SDK attached to your project, most likely. You need to download R12 from the SDK Manager, then attach that library project to your project (replacing whatever version you have today).

Here is a sample project demonstrating the use of rotation() (and flat markers as well).