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;
}
}
}
};
}
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();
}
}
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();
}
}
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();
}
}
}
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();
}
}
Aggregations