Add track start and finish icons to map layer
This commit is contained in:
parent
3bab88942a
commit
03951910fd
1 changed files with 38 additions and 1 deletions
|
@ -10,6 +10,7 @@ import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.LayerDrawable;
|
import android.graphics.drawable.LayerDrawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
@ -41,6 +42,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||||
|
@ -82,10 +84,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private Paint paintIcon;
|
private Paint paintIcon;
|
||||||
private int cachedHash;
|
private int cachedHash;
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
|
private int currentTrackColor;
|
||||||
private float defaultTrackWidth;
|
private float defaultTrackWidth;
|
||||||
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
||||||
private int currentTrackColor;
|
|
||||||
|
|
||||||
|
private Drawable startPointIcon;
|
||||||
|
private Drawable finishPointIcon;
|
||||||
private LayerDrawable selectedPoint;
|
private LayerDrawable selectedPoint;
|
||||||
private TrackChartPoints trackChartPoints;
|
private TrackChartPoints trackChartPoints;
|
||||||
|
|
||||||
|
@ -167,6 +171,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paintIcon = new Paint();
|
paintIcon = new Paint();
|
||||||
selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default);
|
selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default);
|
||||||
|
|
||||||
|
UiUtilities iconsCache = view.getApplication().getUIUtilities();
|
||||||
|
startPointIcon = iconsCache.getIcon(R.drawable.map_track_point_start);
|
||||||
|
finishPointIcon = iconsCache.getIcon(R.drawable.map_track_point_finish);
|
||||||
|
|
||||||
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
||||||
|
|
||||||
visitedColor = ContextCompat.getColor(view.getApplication(), R.color.color_ok);
|
visitedColor = ContextCompat.getColor(view.getApplication(), R.color.color_ok);
|
||||||
|
@ -201,6 +209,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
||||||
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
||||||
|
drawSelectedFilesStartEndPoints(canvas, tileBox, selectedGPXFiles);
|
||||||
}
|
}
|
||||||
if (textLayer != null && isTextVisible()) {
|
if (textLayer != null && isTextVisible()) {
|
||||||
textLayer.putData(this, cache);
|
textLayer.putData(this, cache);
|
||||||
|
@ -383,6 +392,34 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
|
if (selectedGpxFile.getGpxFile().isShowStartFinish()) {
|
||||||
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
|
TrkSegment endSegment = segments.get(segments.size() - 1);
|
||||||
|
|
||||||
|
WptPt start = segments.get(0).points.get(0);
|
||||||
|
WptPt end = endSegment.points.get(endSegment.points.size() - 1);
|
||||||
|
|
||||||
|
drawPoint(canvas, tileBox, start, startPointIcon);
|
||||||
|
drawPoint(canvas, tileBox, end, finishPointIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) {
|
||||||
|
int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon);
|
||||||
|
int pointY = (int) tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon);
|
||||||
|
|
||||||
|
icon.setBounds(pointX - icon.getIntrinsicWidth() / 2,
|
||||||
|
pointY - icon.getIntrinsicHeight() / 2,
|
||||||
|
pointX + icon.getIntrinsicWidth() / 2,
|
||||||
|
pointY + icon.getIntrinsicHeight() / 2);
|
||||||
|
icon.draw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
float textScale = view.getSettings().TEXT_SCALE.get();
|
float textScale = view.getSettings().TEXT_SCALE.get();
|
||||||
|
|
Loading…
Reference in a new issue