Current location move graph to one-fourth of the visible range

This commit is contained in:
Vitaliy 2020-07-28 14:52:36 +03:00
parent 17e1af1e51
commit f449ae598b

View file

@ -148,7 +148,13 @@ public class TrackDetailsMenu {
LatLon latLon = tb.getLatLonFromPixel(mx, my);
gpxItem.locationOnMap = GPXLayer.createProjectionPoint(points.first, points.second, latLon);
float pos = (float) (gpxItem.locationOnMap.distance / ((OrderedLineDataSet) ds.get(0)).getDivX());
float nextVisibleX = chart.getLowestVisibleX() + (pos - gpxItem.chartHighlightPos);
float lowestVisibleX = chart.getLowestVisibleX();
float highestVisibleX = chart.getHighestVisibleX();
float nextVisibleX = lowestVisibleX + (pos - gpxItem.chartHighlightPos);
float oneFourthDiff = (highestVisibleX - lowestVisibleX) / 4f;
if (pos - oneFourthDiff > 0) {
nextVisibleX = pos - oneFourthDiff;
}
gpxItem.chartHighlightPos = pos;
chart.moveViewToX(nextVisibleX);