I am afraid of how to make a movement with the camera to fit my two markers and keep them level. Thus, this implies zooming in to match them and rotating the camera to match markers on the same line.
The following two photos will clarify my question:


So what I have done so far:
public void centerIncidentRouteOnMap(List<LatLng> copiedPoints) {
double minLat = Integer.MAX_VALUE;
double maxLat = Integer.MIN_VALUE;
double minLon = Integer.MAX_VALUE;
double maxLon = Integer.MIN_VALUE;
for (LatLng point : copiedPoints) {
maxLat = Math.max(point.latitude, maxLat);
minLat = Math.min(point.latitude, minLat);
maxLon = Math.max(point.longitude, maxLon);
minLon = Math.min(point.longitude, minLon);
}
final LatLngBounds bounds = new LatLngBounds.Builder().include(new LatLng(maxLat, maxLon)).include(new LatLng(minLat, minLon)).build();
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 120));
}
But this only makes the two markers suitable on the screen, so I need to know how to rotate the camera with the right angle to get the last picture.
Can someone help me with this?
Thank!
source
share