Skip to content

Commit

Permalink
Fix #21453 Map goes to the ocean
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRe1nk0 committed Dec 19, 2024
1 parent 8836ef2 commit 5f2a311
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public class DownloadTilesFragment extends BaseOsmAndFragment implements IMapLoc
private LockableScrollView scrollView;
private IMapLocationListener mapLocationListener;
private TouchListener touchListener;
private double lat;
private double lon;
private Double lat = null;
private Double lon = null;
private boolean portraitMode;

@Override
Expand Down Expand Up @@ -183,6 +183,9 @@ public void onGlobalLayout() {
updateTileSourceContent();
}
});
if (lat == null || lon == null) {
updateLatLon();
}
setupDownloadButton();
showHideMapControls(false);
setupScrollableMapView();
Expand Down Expand Up @@ -222,12 +225,14 @@ private void setupScrollableMapView() {

@NonNull
private IMapLocationListener getMapLocationListener() {
return (v, v1, o) -> {
QuadRect rect = getLatLonRectOfMapWindow();
LatLon mapWindowCenter = new LatLon(rect.centerY(), rect.centerX());
lat = mapWindowCenter.getLatitude();
lon = mapWindowCenter.getLongitude();
};
return (v, v1, o) -> updateLatLon();
}

private void updateLatLon(){
QuadRect rect = getLatLonRectOfMapWindow();
LatLon mapWindowCenter = new LatLon(rect.centerY(), rect.centerX());
lat = mapWindowCenter.getLatitude();
lon = mapWindowCenter.getLongitude();
}

@NonNull
Expand Down

0 comments on commit 5f2a311

Please sign in to comment.