Search in sources :

Example 16 with OsmandMapTileView

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

the class MeasurementToolFragment method createMeasurementAdapterListener.

private MeasurementAdapterListener createMeasurementAdapterListener(final ItemTouchHelper touchHelper) {
    return new MeasurementAdapterListener() {

        final MapActivity mapActivity = getMapActivity();

        final MeasurementToolLayer measurementLayer = getMeasurementLayer();

        private int fromPosition;

        private int toPosition;

        @Override
        public void onRemoveClick(int position) {
            if (measurementLayer != null) {
                removePoint(measurementLayer, position);
            }
        }

        @Override
        public void onItemClick(int position) {
            if (mapActivity != null && measurementLayer != null) {
                if (pointsListOpened) {
                    hidePointsList();
                }
                OsmandMapTileView tileView = mapActivity.getMapView();
                if (portrait) {
                    previousMapPosition = tileView.getMapPosition();
                    tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
                }
                mapActivity.refreshMap();
                measurementLayer.moveMapToPoint(position);
                measurementLayer.selectPoint(position);
            }
        }

        @Override
        public void onDragStarted(RecyclerView.ViewHolder holder) {
            fromPosition = holder.getAdapterPosition();
            touchHelper.startDrag(holder);
        }

        @Override
        public void onDragEnded(RecyclerView.ViewHolder holder) {
            if (mapActivity != null && measurementLayer != null) {
                toPosition = holder.getAdapterPosition();
                if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
                    editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
                    adapter.notifyDataSetChanged();
                    disable(redoBtn);
                    updateText();
                    mapActivity.refreshMap();
                    saved = false;
                }
            }
        }
    };
}
Also used : ReorderPointCommand(net.osmand.plus.measurementtool.command.ReorderPointCommand) MeasurementAdapterListener(net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 17 with OsmandMapTileView

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

the class MeasurementToolFragment method showPointsList.

private void showPointsList() {
    pointsListOpened = true;
    upDownBtn.setImageDrawable(downIcon);
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        if (portrait && pointsListContainer != null) {
            pointsListContainer.setVisibility(View.VISIBLE);
        } else {
            showPointsListFragment();
        }
        OsmandMapTileView tileView = mapActivity.getMapView();
        previousMapPosition = tileView.getMapPosition();
        if (portrait) {
            tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
        } else {
            tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
        }
        mapActivity.refreshMap();
    }
}
Also used : OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 18 with OsmandMapTileView

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

the class PlanRouteFragment method enterPlanRouteMode.

private void enterPlanRouteMode() {
    final MapActivity mapActivity = getMapActivity();
    MapMarkersLayer markersLayer = getMapMarkersLayer();
    if (mapActivity != null && markersLayer != null) {
        markersLayer.setInPlanRouteMode(true);
        mapActivity.disableDrawer();
        mark(portrait ? View.INVISIBLE : View.GONE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
        mark(View.GONE, R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button, R.id.map_search_button, R.id.map_quick_actions_button);
        View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
        if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
            wasCollapseButtonVisible = true;
            collapseButton.setVisibility(View.INVISIBLE);
        } else {
            wasCollapseButtonVisible = false;
        }
        if (planRouteContext.getSnappedMode() == null) {
            planRouteContext.setSnappedMode(ApplicationMode.DEFAULT);
        }
        setupAppModesBtn();
        OsmandMapTileView tileView = mapActivity.getMapView();
        previousMapPosition = tileView.getMapPosition();
        tileView.setMapPosition(portrait ? MIDDLE_TOP_CONSTANT : LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
        selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
        planRouteContext.recreateSnapTrkSegment(planRouteContext.isAdjustMapOnStart());
        planRouteContext.setAdjustMapOnStart(true);
        mapActivity.refreshMap();
        updateSelectButton();
    }
}
Also used : MapMarkersLayer(net.osmand.plus.views.MapMarkersLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RecyclerView(android.support.v7.widget.RecyclerView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 19 with OsmandMapTileView

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

the class PlanRouteFragment method moveMapToPosition.

private void moveMapToPosition(double lat, double lon) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        OsmandMapTileView view = mapActivity.getMapView();
        view.getAnimatedDraggingThread().startMoving(lat, lon, view.getZoom(), true);
        if (planRouteContext.isMarkersListOpened()) {
            planRouteContext.setAdjustMapOnStart(false);
            showHideMarkersList();
        }
    }
}
Also used : OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 20 with OsmandMapTileView

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

the class MapillaryImageDialog method setImageLocation.

private void setImageLocation(LatLon latLon, double ca, boolean animated) {
    OsmandMapTileView mapView = getMapActivity().getMapView();
    updateLayer(mapView.getLayerByClass(MapillaryRasterLayer.class), latLon, ca);
    updateLayer(mapView.getLayerByClass(MapillaryVectorLayer.class), latLon, ca);
    if (latLon != null) {
        if (animated) {
            mapView.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), mapView.getZoom(), true);
        } else {
            getMapActivity().setMapLocation(latLon.getLatitude(), latLon.getLongitude());
        }
    } else {
        getMapActivity().refreshMap();
    }
}
Also used : OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView)

Aggregations

OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)25 View (android.view.View)9 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)7 ContextMenuItem (net.osmand.plus.ContextMenuItem)7 ArrayAdapter (android.widget.ArrayAdapter)5 TextView (android.widget.TextView)5 ItemClickListener (net.osmand.plus.ContextMenuAdapter.ItemClickListener)5 OsmandApplication (net.osmand.plus.OsmandApplication)5 OsmandSettings (net.osmand.plus.OsmandSettings)5 DialogInterface (android.content.DialogInterface)4 AlertDialog (android.support.v7.app.AlertDialog)4 AdapterView (android.widget.AdapterView)4 ImageView (android.widget.ImageView)4 MapActivity (net.osmand.plus.activities.MapActivity)4 Intent (android.content.Intent)3 ListView (android.widget.ListView)3 ArrayList (java.util.ArrayList)3 Location (net.osmand.Location)3 LatLon (net.osmand.data.LatLon)3 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)3