com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException Java Examples

The following examples show how to use com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavigationLauncherActivity.java    From graphhopper-navigation-android with MIT License 6 votes vote down vote up
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();
      }
    }
  }
}
 
Example #2
Source File: NavigationLauncherActivity.java    From graphhopper-navigation-example with Apache License 2.0 6 votes vote down vote up
private 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
                animateCameraBbox(bounds, CAMERA_ANIMATION_DURATION, padding);
            } catch (InvalidLatLngBoundsException exception) {
                Toast.makeText(this, R.string.error_valid_route_not_found, Toast.LENGTH_SHORT).show();
            }
        }
    }
}
 
Example #3
Source File: MapDataManager.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDataCollectionFinished() {
    for (MapSource source : contactMapSources.values()) {
        initContactBasedLayers(source);
        refreshSource(source.getContactId());
        applyMarkerFilter(source);
        applyLineFilter(source);
    }

    if (boundingBuilder != null && callback != null) {
        LatLngBounds bound = null;
        try {
            bound = boundingBuilder.build();
        } catch (InvalidLatLngBoundsException e) {
            Log.w(TAG, e.getLocalizedMessage());
        }
        callback.onDataInitialized(bound);
    }
}