use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class FavoritesTreeFragment method showOnMap.
public void showOnMap(final FavouritePoint point) {
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
final OsmandSettings settings = getMyApplication().getSettings();
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapControlsLayer method replaceDestination.
public void replaceDestination(LatLon latLon) {
RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
if (latLon != null) {
if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
PointDescription pointDescription = getPointDescriptionForTarget(latLon);
mapActivity.getContextMenu().close();
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(latLon, true, -1, pointDescription);
} else {
addDestination(latLon);
}
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapControlsLayer method addDestination.
public void addDestination(LatLon latLon) {
if (latLon != null) {
if (!OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
requestedLatLon = latLon;
ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION);
} else {
PointDescription pointDescription = getPointDescriptionForTarget(latLon);
mapActivity.getContextMenu().close();
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
targets.navigateToPoint(latLon, true, targets.getIntermediatePoints().size() + 1, pointDescription);
} else if (targets.getIntermediatePoints().isEmpty()) {
startRoutePlanningWithDestination(latLon, pointDescription, targets);
}
}
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapContextMenu method init.
public boolean init(@NonNull LatLon latLon, @Nullable PointDescription pointDescription, @Nullable Object object, boolean update, boolean restorePrevious) {
OsmandApplication app = mapActivity.getMyApplication();
if (myLocation == null) {
updateMyLocation(app.getLocationProvider().getLastKnownLocation(), false);
}
if (!update && isVisible()) {
if (this.object == null || !this.object.equals(object)) {
hide();
} else {
return false;
}
}
setSelectedObject(object);
if (pointDescription == null) {
this.pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
} else {
this.pointDescription = pointDescription;
}
boolean needAcquireMenuController = menuController == null || appModeChanged || !update || this.object == null && object != null || this.object != null && object == null || (this.object != null && object != null && !this.object.getClass().equals(object.getClass()));
this.latLon = latLon;
this.object = object;
active = true;
appModeChanged = false;
if (needAcquireMenuController) {
if (menuController != null) {
menuController.setMapContextMenu(null);
}
if (!acquireMenuController(restorePrevious)) {
active = false;
clearSelectedObject(object);
return false;
}
} else {
menuController.update(pointDescription, object);
}
initTitle();
if (menuController != null) {
menuController.clearPlainMenuItems();
menuController.addPlainMenuItems(typeStr, this.pointDescription, this.latLon);
}
if (mapPosition != 0) {
mapActivity.getMapView().setMapPosition(0);
}
mapActivity.refreshMap();
if (object instanceof MapMarker) {
app.getMapMarkersHelper().addListener(this);
} else if (object instanceof TargetPoint) {
app.getTargetPointsHelper().addPointListener(this);
}
return true;
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MenuBuilder method getCollapsableWikiView.
protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
for (final Amenity wiki : nearestWiki) {
TextViewEx button = buildButtonInCollapsableView(context, false, false);
String name = wiki.getName(preferredMapAppLang, transliterateNames);
button.setText(name);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude());
PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
mapActivity.getContextMenu().show(latLon, pointDescription, wiki);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
Aggregations