Search in sources :

Example 1 with NewGpxPoint

use of net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint in project Osmand by osmandapp.

the class TrackActivity method addPoint.

public void addPoint(PointDescription pointDescription) {
    Intent currentIntent = getIntent();
    if (currentIntent != null) {
        currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
    }
    final OsmandSettings settings = app.getSettings();
    GPXFile gpx = getGpx();
    LatLon location = settings.getLastKnownMapLocation();
    QuadRect rect = getRect();
    NewGpxPoint newGpxPoint = new NewGpxPoint(gpx, pointDescription, rect);
    if (gpx != null && location != null) {
        settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), pointDescription, false, newGpxPoint);
        MapActivity.launchMapActivityMoveToTop(this);
    }
}
Also used : LatLon(net.osmand.data.LatLon) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) Intent(android.content.Intent) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) QuadRect(net.osmand.data.QuadRect) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 2 with NewGpxPoint

use of net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint in project Osmand by osmandapp.

the class MapActivity method readLocationToShow.

public void readLocationToShow() {
    if (!getDashboard().isVisible()) {
        mapLayers.getMapControlsLayer().showMapControlsIfHidden();
    }
    LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
    LatLon latLonToShow = settings.getAndClearMapLocationToShow();
    PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);
    Object toShow = settings.getAndClearObjectToShow();
    boolean editToShow = settings.getAndClearEditObjectToShow();
    int status = settings.isRouteToPointNavigateAndClear();
    String searchRequestToShow = settings.getAndClearSearchRequestToShow();
    if (status != 0) {
        // always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
        Location loc = new Location("map");
        loc.setLatitude(mapView.getLatitude());
        loc.setLongitude(mapView.getLongitude());
        getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
        if (dashboardOnMap.isVisible()) {
            dashboardOnMap.hideDashboard();
        }
    }
    if (searchRequestToShow != null) {
        showQuickSearch(searchRequestToShow);
    }
    if (latLonToShow != null) {
        if (dashboardOnMap.isVisible()) {
            dashboardOnMap.hideDashboard();
        }
        // remember if map should come back to isMapLinkedToLocation=true
        mapViewTrackingUtilities.setMapLinkedToLocation(false);
        if (mapLabelToShow != null && !mapLabelToShow.contextMenuDisabled()) {
            mapContextMenu.setMapCenter(latLonToShow);
            mapContextMenu.setMapPosition(mapView.getMapPosition());
            mapContextMenu.setCenterMarker(true);
            RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
            LatLon prevCenter = tb.getCenterLatLon();
            double border = 0.8;
            int tbw = (int) (tb.getPixWidth() * border);
            int tbh = (int) (tb.getPixHeight() * border);
            tb.setPixelDimensions(tbw, tbh);
            tb.setLatLonCenter(latLonToShow.getLatitude(), latLonToShow.getLongitude());
            tb.setZoom(ZOOM_LABEL_DISPLAY);
            while (!tb.containsLatLon(prevCenter.getLatitude(), prevCenter.getLongitude()) && tb.getZoom() > MIN_ZOOM_LABEL_DISPLAY) {
                tb.setZoom(tb.getZoom() - 1);
            }
            // mapContextMenu.setMapZoom(settings.getMapZoomToShow());
            mapContextMenu.setMapZoom(tb.getZoom());
            if (toShow instanceof GpxDisplayItem) {
                TrackDetailsMenu trackDetailsMenu = mapLayers.getMapControlsLayer().getTrackDetailsMenu();
                trackDetailsMenu.setGpxItem((GpxDisplayItem) toShow);
                trackDetailsMenu.show();
            } else if (MapRouteInfoMenu.isVisible()) {
                mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow);
                mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu();
                MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
            } else if (toShow instanceof QuadRect) {
                QuadRect qr = (QuadRect) toShow;
                mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
            } else if (toShow instanceof NewGpxPoint) {
                NewGpxPoint newGpxPoint = (NewGpxPoint) toShow;
                QuadRect qr = newGpxPoint.getRect();
                mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
                getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint);
            } else if (toShow instanceof NewGpxData) {
                NewGpxData newGpxData = (NewGpxData) toShow;
                QuadRect qr = newGpxData.getRect();
                mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
                MeasurementEditingContext editingContext = new MeasurementEditingContext();
                editingContext.setNewGpxData(newGpxData);
                MeasurementToolFragment.showInstance(getSupportFragmentManager(), editingContext);
            } else {
                mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
            }
            if (editToShow) {
                mapContextMenu.openEditor();
            }
        } else if (!latLonToShow.equals(cur)) {
            mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);
        }
    }
}
Also used : MeasurementEditingContext(net.osmand.plus.measurementtool.MeasurementEditingContext) RotatedTileBox(net.osmand.data.RotatedTileBox) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) QuadRect(net.osmand.data.QuadRect) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) LatLon(net.osmand.data.LatLon) TrackDetailsMenu(net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu) PointDescription(net.osmand.data.PointDescription) NewGpxData(net.osmand.plus.measurementtool.NewGpxData) Location(net.osmand.Location)

Aggregations

LatLon (net.osmand.data.LatLon)2 QuadRect (net.osmand.data.QuadRect)2 NewGpxPoint (net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)2 Intent (android.content.Intent)1 Location (net.osmand.Location)1 PointDescription (net.osmand.data.PointDescription)1 QuadPoint (net.osmand.data.QuadPoint)1 RotatedTileBox (net.osmand.data.RotatedTileBox)1 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)1 GpxDisplayItem (net.osmand.plus.GpxSelectionHelper.GpxDisplayItem)1 OsmandSettings (net.osmand.plus.OsmandSettings)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 TrackDetailsMenu (net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu)1 MeasurementEditingContext (net.osmand.plus.measurementtool.MeasurementEditingContext)1 NewGpxData (net.osmand.plus.measurementtool.NewGpxData)1