use of com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException in project mapbox-navigation-android by mapbox.
the class NavigationViewActivity method boundCameraToRoute.
public void boundCameraToRoute() {
if (route != null) {
List<Point> routeCoords = LineString.fromPolyline(route.geometry(), Constants.PRECISION_6).coordinates();
List<LatLng> bboxPoints = new ArrayList<>();
for (Point point : routeCoords) {
bboxPoints.add(new LatLng(point.latitude(), point.longitude()));
}
if (bboxPoints.size() > 1) {
try {
LatLngBounds bounds = new LatLngBounds.Builder().includes(bboxPoints).build();
// left, top, right, bottom
int topPadding = launchBtnFrame.getHeight() * 2;
animateCameraBbox(bounds, CAMERA_ANIMATION_DURATION, new int[] { 50, topPadding, 50, 100 });
} catch (InvalidLatLngBoundsException exception) {
Toast.makeText(this, R.string.error_valid_route_not_found, Toast.LENGTH_SHORT).show();
}
}
}
}
Aggregations