Search in sources :

Example 21 with MapMarkersHelper

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

the class MapMarkersLayer method applyNewObjectPosition.

@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ApplyMovedObjectCallback callback) {
    boolean result = false;
    MapMarker newObject = null;
    if (o instanceof MapMarker) {
        MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
        MapMarker marker = (MapMarker) o;
        PointDescription originalDescription = marker.getOriginalPointDescription();
        if (originalDescription.isLocation()) {
            originalDescription.setName(PointDescription.getSearchAddressStr(map));
        }
        markersHelper.moveMapMarker(marker, position);
        int index = markersHelper.getMapMarkers().indexOf(marker);
        if (index != -1) {
            newObject = markersHelper.getMapMarkers().get(index);
        }
        result = true;
    }
    if (callback != null) {
        callback.onApplyMovedObject(result, newObject == null ? o : newObject);
    }
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription) 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