use of net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu 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);
}
}
}
use of net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu in project Osmand by osmandapp.
the class MapControlsLayer method initRouteControls.
private void initRouteControls() {
mapRouteInfoMenu = new MapRouteInfoMenu(mapActivity, this);
trackDetailsMenu = new TrackDetailsMenu(mapActivity);
}
use of net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu in project Osmand by osmandapp.
the class MapMarkerSelectionFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle bundle = null;
if (getArguments() != null) {
bundle = getArguments();
} else if (savedInstanceState != null) {
bundle = savedInstanceState;
}
if (bundle != null) {
target = bundle.getBoolean(TARGET_KEY);
intermediate = bundle.getBoolean(INTERMEDIATE_KEY);
}
MapActivity mapActivity = getMapActivity();
OsmandApplication app = getMyApplication();
if (mapActivity != null) {
MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
onClickListener = routeInfoMenu.getOnMarkerSelectListener();
screenOrientation = DashLocationFragment.getScreenOrientation(mapActivity);
MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
if (trackingUtils != null) {
Float head = trackingUtils.getHeading();
float mapRotation = mapActivity.getMapRotate();
LatLon mw = mapActivity.getMapLocation();
Location l = trackingUtils.getMyLocation();
boolean mapLinked = trackingUtils.isMapLinkedToLocation() && l != null;
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
useCenter = !mapLinked;
loc = (useCenter ? mw : myLoc);
if (useCenter) {
heading = -mapRotation;
} else {
heading = head;
}
}
}
nightMode = !app.getSettings().isLightContent();
View view = inflater.inflate(R.layout.map_marker_selection_fragment, container, false);
ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton);
closeButton.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_mode_back));
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getMapMarkers();
if (markers.size() > 0) {
for (MapMarker marker : markers) {
adapter.add(marker);
}
}
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (onClickListener != null) {
onClickListener.onSelect(position, target, intermediate);
}
dismiss();
}
});
return view;
}
use of net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu in project Osmand by osmandapp.
the class ShowRouteInfoDialogFragment method openDetails.
void openDetails() {
if (gpxItem != null) {
LatLon location = null;
WptPt wpt = null;
gpxItem.chartTypes = new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE };
if (gpxItem.chartHighlightPos != -1) {
TrkSegment segment = gpx.tracks.get(0).segments.get(0);
if (segment != null) {
float distance = gpxItem.chartHighlightPos * elevationDataSet.getDivX();
for (WptPt p : segment.points) {
if (p.distance >= distance) {
wpt = p;
break;
}
}
if (wpt != null) {
location = new LatLon(wpt.lat, wpt.lon);
}
}
}
if (location == null) {
location = new LatLon(gpxItem.locationStart.lat, gpxItem.locationStart.lon);
}
if (wpt != null) {
gpxItem.locationOnMap = wpt;
} else {
gpxItem.locationOnMap = gpxItem.locationStart;
}
final MapActivity activity = (MapActivity) getActivity();
if (activity != null) {
dismiss();
final OsmandSettings settings = activity.getMyApplication().getSettings();
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), false, gpxItem);
final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
if (MapRouteInfoMenu.isVisible()) {
// We arrived here by the route info menu.
// First, we close it and then show the details.
mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mapRouteInfoMenu.setOnDismissListener(null);
MapActivity.launchMapActivityMoveToTop(activity);
}
});
mapRouteInfoMenu.hide();
} else {
// We arrived here by the dashboard.
MapActivity.launchMapActivityMoveToTop(activity);
}
}
}
}
Aggregations