Thomas
Thomas

Reputation: 103

Google Map Marker Rotation not change when rotate map

I am using android Google Map API v2 to build a navigation application on android phone. For direction of movement, I used a marker with arrow image as the marker (the image have a dot and a arrow on top of it). I tried to use .rotation to set orientation of the marker according to the direction of movement. The problem is that when I rotate Google Map, the Map's rotation change but the orientation of marker is unchanged. I am looking for a way to set rotation of the marker relative to Map's rotation (so when an user rotate map, the marker will rotate accordingly). Or if anyone know how to build direction arrow other than my primitive way, please enlighten me. Thank you :)

Upvotes: 1

Views: 4986

Answers (2)

Rachel Gallen
Rachel Gallen

Reputation: 28583

call setRotation and that will do the trick!

e.g.

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));

Code Ref

Upvotes: 2

todd
todd

Reputation: 1286

By default, markers are oriented against the screen, and will not rotate or tilt with the camera. Flat markers are oriented against the surface of the earth, and will rotate and tilt with the camera.

You can make the marker flat by calling flat(true) as in the following example:

Marker perth = mMap.addMarker(new MarkerOptions()
                      .position(PERTH)
                      .flat(true));

Upvotes: 8

Related Questions