Reputation: 103
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
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));
Upvotes: 2
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