Search in sources :

Example 61 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class TargetPointsHelper method navigateToPoint.

public void navigateToPoint(final LatLon point, boolean updateRoute, int intermediate, PointDescription historyName) {
    if (point != null) {
        final PointDescription pointDescription;
        if (historyName == null) {
            pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
        } else {
            pointDescription = historyName;
        }
        if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
            pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
        }
        if (intermediate < 0 || intermediate > intermediatePoints.size()) {
            if (intermediate > intermediatePoints.size()) {
                final TargetPoint pn = getPointToNavigate();
                if (pn != null) {
                    settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), pn.pointDescription, intermediatePoints.size());
                }
            }
            settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), pointDescription);
        } else {
            settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), pointDescription, intermediate);
        }
    } else {
        cancelTargetPointAddressRequest();
        cancelAllIntermediatePointsAddressRequests();
        settings.clearPointToNavigate();
        settings.clearIntermediatePoints();
    }
    readFromSettings();
    updateRouteAndRefresh(updateRoute);
}
Also used : PointDescription(net.osmand.data.PointDescription)

Example 62 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class OsmandAidlApi method addMapMarker.

boolean addMapMarker(AMapMarker marker) {
    if (marker != null) {
        PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, marker.getName() != null ? marker.getName() : "");
        MapMarkersHelper markersHelper = app.getMapMarkersHelper();
        markersHelper.addMapMarker(new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude()), pd);
        refreshMap();
        return true;
    } else {
        return false;
    }
}
Also used : LatLon(net.osmand.data.LatLon) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription)

Example 63 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class OsmandAidlApi method updateMapMarker.

boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew) {
    if (markerPrev != null && markerNew != null) {
        LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude());
        LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude());
        MapMarkersHelper markersHelper = app.getMapMarkersHelper();
        List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
        for (MapMarker m : mapMarkers) {
            if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
                PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
                MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
                marker.id = m.id;
                marker.creationDate = m.creationDate;
                marker.visitedDate = m.visitedDate;
                markersHelper.moveMapMarker(marker, latLonNew);
                refreshMap();
                return true;
            }
        }
        return false;
    } else {
        return false;
    }
}
Also used : LatLon(net.osmand.data.LatLon) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) AMapMarker(net.osmand.aidl.mapmarker.AMapMarker) PointDescription(net.osmand.data.PointDescription)

Example 64 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapControlsLayer method getPointDescriptionForTarget.

private PointDescription getPointDescriptionForTarget(LatLon latLon) {
    final MapContextMenu menu = mapActivity.getContextMenu();
    PointDescription pointDescription;
    if (menu.isActive() && latLon.equals(menu.getLatLon())) {
        pointDescription = menu.getPointDescriptionForTarget();
    } else {
        pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
    }
    return pointDescription;
}
Also used : PointDescription(net.osmand.data.PointDescription) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Example 65 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapControlsLayer method addFirstIntermediate.

public void addFirstIntermediate(LatLon latLon) {
    if (latLon != null) {
        RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
        if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
            PointDescription pointDescription = getPointDescriptionForTarget(latLon);
            mapActivity.getContextMenu().close();
            final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
            if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
                targets.navigateToPoint(latLon, true, 0, pointDescription);
            } else if (targets.getIntermediatePoints().isEmpty()) {
                startRoutePlanningWithDestination(latLon, pointDescription, targets);
            }
        } else {
            addDestination(latLon);
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

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