Search in sources :

Example 1 with AMapMarker

use of net.osmand.aidl.mapmarker.AMapMarker 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 2 with AMapMarker

use of net.osmand.aidl.mapmarker.AMapMarker 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)

Aggregations

AMapMarker (net.osmand.aidl.mapmarker.AMapMarker)2 LatLon (net.osmand.data.LatLon)2 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)2 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)2 PointDescription (net.osmand.data.PointDescription)1