Цель состоит в том, чтобы маркер поворачивался в направлении следующей координатной точки. Вот метод, чтобы получить угол:Невозможно повернуть маркер с помощью карт google v.2
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)));
}
А вот код, где я создаю маркер:
@Override
public void onMapReady(GoogleMap googleMap) {
//Unnecessary code is 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);
}
Таким образом, я не могу понять, в чем проблема. Кажется, все в порядке, но ничего не работает, можете ли вы мне помочь?
попытаться преобразовать его в градусы, как 'Math.toDegrees (радианы)' – injecteer
Это не помогло. – SanchelliosProg