Search in sources :

Example 16 with MapMarkersHelper

use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.

the class FavoritesTreeFragment method selectMapMarkersImpl.

private void selectMapMarkersImpl() {
    if (getSelectedFavoritesCount() > 0) {
        MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
        List<LatLon> points = new ArrayList<>();
        List<PointDescription> names = new ArrayList<>();
        for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
            FavoriteGroup favGr = helper.getGroup(entry.getKey());
            MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(favGr);
            if (entry.getValue().size() == favGr.points.size()) {
                markersHelper.addOrEnableGroup(markersGr);
            } else {
                for (FavouritePoint fp : entry.getValue()) {
                    points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
                    names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
                }
                markersHelper.addMapMarkers(points, names, markersGr);
                points.clear();
                names.clear();
            }
        }
        MapActivity.launchMapActivityMoveToTop(getActivity());
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) FavouritePoint(net.osmand.data.FavouritePoint) FavoriteGroup(net.osmand.plus.FavouritesDbHelper.FavoriteGroup) ArrayList(java.util.ArrayList) LatLon(net.osmand.data.LatLon) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription) MapMarkersGroup(net.osmand.plus.MapMarkersHelper.MapMarkersGroup) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with MapMarkersHelper

use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.

the class OsmandAidlApi method removeMapMarker.

boolean removeMapMarker(AMapMarker marker) {
    if (marker != null) {
        LatLon latLon = new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude());
        MapMarkersHelper markersHelper = app.getMapMarkersHelper();
        List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
        for (MapMarker m : mapMarkers) {
            if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
                markersHelper.moveMapMarkerToHistory(m);
                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)

Example 18 with MapMarkersHelper

use of net.osmand.plus.MapMarkersHelper 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 19 with MapMarkersHelper

use of net.osmand.plus.MapMarkersHelper 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 20 with MapMarkersHelper

use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.

the class MapMarkersLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
    widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom());
    OsmandSettings settings = map.getMyApplication().getSettings();
    if (tileBox.getZoom() < 3) {
        return;
    }
    int displayedWidgets = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
    MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
    for (MapMarker marker : markersHelper.getMapMarkers()) {
        if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker) && !isInMotion(marker) && !isSynced(marker)) {
            Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
            int marginX = bmp.getWidth() / 6;
            int marginY = bmp.getHeight();
            int locationX = tileBox.getPixXFromLonNoRot(marker.getLongitude());
            int locationY = tileBox.getPixYFromLatNoRot(marker.getLatitude());
            canvas.rotate(-tileBox.getRotate(), locationX, locationY);
            canvas.drawBitmap(bmp, locationX - marginX, locationY - marginY, bitmapPaint);
            canvas.rotate(tileBox.getRotate(), locationX, locationY);
        }
    }
    if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
        LatLon loc = tileBox.getCenterLatLon();
        int i = 0;
        for (MapMarker marker : markersHelper.getMapMarkers()) {
            if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
                canvas.save();
                net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), marker.getLatitude(), marker.getLongitude(), calculations);
                float bearing = calculations[1] - 90;
                float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
                final QuadPoint cp = tileBox.getCenterPixelPoint();
                canvas.rotate(bearing, cp.x, cp.y);
                canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
                canvas.drawBitmap(arrowShadow, cp.x, cp.y, bitmapPaint);
                canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
                canvas.drawBitmap(arrowLight, cp.x, cp.y, bitmapPaint);
                canvas.restore();
            }
            i++;
            if (i > displayedWidgets - 1) {
                break;
            }
        }
    }
    if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
        MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
        PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
        Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
        int marginX = bitmap.getWidth() / 6;
        int marginY = bitmap.getHeight();
        float locationX = pf.x;
        float locationY = pf.y;
        canvas.rotate(-tileBox.getRotate(), locationX, locationY);
        canvas.drawBitmap(bitmap, locationX - marginX, locationY - marginY, bitmapPaint);
    }
}
Also used : LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) QuadPoint(net.osmand.data.QuadPoint) PointF(android.graphics.PointF) OsmandSettings(net.osmand.plus.OsmandSettings) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint)

Aggregations

MapMarkersHelper (net.osmand.plus.MapMarkersHelper)21 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)10 LatLon (net.osmand.data.LatLon)9 MapMarkersGroup (net.osmand.plus.MapMarkersHelper.MapMarkersGroup)7 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)6 View (android.view.View)5 PointDescription (net.osmand.data.PointDescription)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Paint (android.graphics.Paint)3 ImageView (android.widget.ImageView)3 Location (net.osmand.Location)3 FavouritePoint (net.osmand.data.FavouritePoint)3 QuadPoint (net.osmand.data.QuadPoint)3 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)3 DialogInterface (android.content.DialogInterface)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 SearchView (android.support.v7.widget.SearchView)2 TextView (android.widget.TextView)2