@Override public void zoomToFit(List<Coord2D> coords) { if (coords.isEmpty()) { return; } final ArrayList<LatLng> boxCoords = new ArrayList<LatLng>(coords.size()); for (Coord2D coord : coords) { boxCoords.add(DroneHelper.CoordToLatLng(coord)); } final BoundingBox enclosingBounds = BoundingBox.fromLatLngs(boxCoords); mMapView.zoomToBoundingBox(enclosingBounds, true, true, true); }
/** Initializes the track path and the bounding boxes required by the mapviews. */ private void initPath() { mPoints = new ArrayList<PointF>(); mValues = new ArrayList<>(); List<Measurement> measurementList = mTrack.getMeasurements(); double maxLatitude = Double.MIN_VALUE; double minLatitude = Double.MAX_VALUE; double maxLongitude = Double.MIN_VALUE; double minLongitude = Double.MAX_VALUE; // For each measurement value add the longitude and latitude coordinates as a new // mappoint to the overlay network. In addition, try to find out the maximum and minimum // lon/lat coordinates for the zoom value of the mapview. for (Measurement measurement : measurementList) { double latitude = measurement.getLatitude(); double longitude = measurement.getLongitude(); addPoint(measurement.getLatitude(), measurement.getLongitude()); mValues.add(measurement.getProperty(Measurement.PropertyKey.SPEED)); maxLatitude = Math.max(maxLatitude, latitude); minLatitude = Math.min(minLatitude, latitude); maxLongitude = Math.max(maxLongitude, longitude); minLongitude = Math.min(minLongitude, longitude); } // The bounding box of the pathoverlay. mTrackBoundingBox = new BoundingBox(maxLatitude, maxLongitude, minLatitude, minLongitude); // The view bounding box of the pathoverlay mViewBoundingBox = new BoundingBox( mTrackBoundingBox.getLatNorth() + 0.01, mTrackBoundingBox.getLonEast() + 0.01, mTrackBoundingBox.getLatSouth() - 0.01, mTrackBoundingBox.getLonWest() - 0.01); // The bounding box that limits the scrolling of the mapview. mScrollableLimitBox = new BoundingBox( mTrackBoundingBox.getLatNorth() + 0.05, mTrackBoundingBox.getLonEast() + 0.05, mTrackBoundingBox.getLatSouth() - 0.05, mTrackBoundingBox.getLonWest() - 0.05); }