android - Can't rotate marker using google maps v.2 -


the goal make marker rotate towards next coordinate point. here method angle:

private double computeanglebetween(latlng from, latlng to) {     double fromlat = from.latitude;     double fromlng = from.longitude;     double tolat = to.latitude;     double tolng = to.longitude;     double dlat = fromlat - tolat;     double dlng = fromlng - tolng;     return 2 * asin(sqrt(pow(sin(dlat / 2), 2) +             cos(fromlat) * cos(tolat) * pow(sin(dlng / 2), 2))); } 

and here code, create marker:

@override public void onmapready(googlemap googlemap) {     //unnecessary code deleted     float bearing = (float)computeanglebetween(theroute.get(0),theroute.get(1));      marker theairplane = gmap.addmarker(new markeroptions()             .position(start)             .icon(bitmapdescriptorfactory.fromresource(r.drawable.airplane))             .flat(true)             .anchor(0.5f, 0.5f)             .rotation(bearing)             .draggable(true));     theairplane.setrotation(bearing);      moveplane(theairplane, theroute.size()-1);  } 

so, cannot figure out problem. seems alright, nothing works, can me please?

you may use 'setrotation(float rotation)' set rotation of marker. axis of rotation perpendicular marker. rotation of 0 corresponds default position of marker.

make sure have latest play services sdk attached project. need download r12 sdk manager attach library project project.

here sample project demostrate how use 'setrotation': https://github.com/commonsguy/cw-omnibus/tree/master/mapsv2/flatmarkers

here's found answer: maps v2 how rotate marker - rotation option?


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -