Search in sources :

Example 16 with PointDescription

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());
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 17 with PointDescription

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);
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 18 with PointDescription

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);
            }
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 19 with PointDescription

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;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint)

Example 20 with PointDescription

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);
}
Also used : Amenity(net.osmand.data.Amenity) LatLon(net.osmand.data.LatLon) TextViewEx(net.osmand.plus.widgets.TextViewEx) PointDescription(net.osmand.data.PointDescription) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Aggregations

PointDescription (net.osmand.data.PointDescription)72 LatLon (net.osmand.data.LatLon)44 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 ArrayList (java.util.ArrayList)13 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)13 FavouritePoint (net.osmand.data.FavouritePoint)12 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)11 OsmandApplication (net.osmand.plus.OsmandApplication)10 OsmandSettings (net.osmand.plus.OsmandSettings)10 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 Amenity (net.osmand.data.Amenity)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 RoutingHelper (net.osmand.plus.routing.RoutingHelper)7 Intent (android.content.Intent)6 Paint (android.graphics.Paint)6 LinearLayout (android.widget.LinearLayout)6 Location (net.osmand.Location)6 DialogInterface (android.content.DialogInterface)5