Search in sources :

Example 1 with MapRouteInfoMenuFragment

use of net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment in project Osmand by osmandapp.

the class MapActivity method newRouteIsCalculated.

@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
    RoutingHelper rh = app.getRoutingHelper();
    if (newRoute && rh.isRoutePlanningMode() && mapView != null) {
        Location lt = rh.getLastProjection();
        if (lt == null) {
            lt = app.getTargetPointsHelper().getPointToStartLocation();
        }
        if (lt != null) {
            double left = lt.getLongitude(), right = lt.getLongitude();
            double top = lt.getLatitude(), bottom = lt.getLatitude();
            List<Location> list = rh.getCurrentCalculatedRoute();
            for (Location l : list) {
                left = Math.min(left, l.getLongitude());
                right = Math.max(right, l.getLongitude());
                top = Math.max(top, l.getLatitude());
                bottom = Math.min(bottom, l.getLatitude());
            }
            List<TargetPoint> targetPoints = app.getTargetPointsHelper().getIntermediatePointsWithTarget();
            for (TargetPoint l : targetPoints) {
                left = Math.min(left, l.getLongitude());
                right = Math.max(right, l.getLongitude());
                top = Math.max(top, l.getLatitude());
                bottom = Math.min(bottom, l.getLatitude());
            }
            RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
            int tileBoxWidthPx = 0;
            int tileBoxHeightPx = 0;
            MapRouteInfoMenu routeInfoMenu = mapLayers.getMapControlsLayer().getMapRouteInfoMenu();
            WeakReference<MapRouteInfoMenuFragment> fragmentRef = routeInfoMenu.findMenuFragment();
            if (fragmentRef != null) {
                MapRouteInfoMenuFragment f = fragmentRef.get();
                if (landscapeLayout) {
                    tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
                } else {
                    tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
                }
            }
            mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
        }
    }
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) MapRouteInfoMenu(net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) MapRouteInfoMenuFragment(net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) Location(net.osmand.Location)

Aggregations

Location (net.osmand.Location)1 QuadPoint (net.osmand.data.QuadPoint)1 RotatedTileBox (net.osmand.data.RotatedTileBox)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 MapRouteInfoMenu (net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu)1 MapRouteInfoMenuFragment (net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment)1 RoutingHelper (net.osmand.plus.routing.RoutingHelper)1 NewGpxPoint (net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)1