mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Bugfix/nearbby zoomin (#2018)
* Bug Fix #1987 * Increased the default zoom level in nearby to 12 so that user doesnot have to zoom in to see nearby places * updated comments regarding zoom level * updated zoom level to 14 * opening/closing bottom sheet bar would not more hinder the zoom level of the map
This commit is contained in:
parent
ea37245cfd
commit
1b683dee83
1 changed files with 7 additions and 49 deletions
|
|
@ -135,6 +135,8 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
@Inject
|
@Inject
|
||||||
BookmarkLocationsDao bookmarkLocationDao;
|
BookmarkLocationsDao bookmarkLocationDao;
|
||||||
|
|
||||||
|
private static final double ZOOM_LEVEL = 14f;
|
||||||
|
|
||||||
public NearbyMapFragment() {
|
public NearbyMapFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,7 +306,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
curMapBoxLatLng.getLongitude())
|
curMapBoxLatLng.getLongitude())
|
||||||
: curMapBoxLatLng ) // Sets the new camera position
|
: curMapBoxLatLng ) // Sets the new camera position
|
||||||
.zoom(isBottomListSheetExpanded ?
|
.zoom(isBottomListSheetExpanded ?
|
||||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
ZOOM_LEVEL // zoom level is fixed when bottom sheet is expanded
|
||||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||||
.build();
|
.build();
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -314,7 +316,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
curMapBoxLatLng.getLongitude())
|
curMapBoxLatLng.getLongitude())
|
||||||
: curMapBoxLatLng ) // Sets the new camera position
|
: curMapBoxLatLng ) // Sets the new camera position
|
||||||
.zoom(isBottomListSheetExpanded ?
|
.zoom(isBottomListSheetExpanded ?
|
||||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
ZOOM_LEVEL // zoom level is fixed when bottom sheet is expanded
|
||||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
@ -325,47 +327,6 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates camera position according to list sheet status. If list sheet is collapsed, camera
|
|
||||||
* focus should be in the center. If list sheet is expanded, camera focus should be visible
|
|
||||||
* on the gap between list sheet and tab layout.
|
|
||||||
* @param isBottomListSheetExpanded
|
|
||||||
*/
|
|
||||||
private void updateMapCameraAccordingToBottomSheet(boolean isBottomListSheetExpanded) {
|
|
||||||
CameraPosition position;
|
|
||||||
this.isBottomListSheetExpanded = isBottomListSheetExpanded;
|
|
||||||
if (mapboxMap != null && curLatLng != null) {
|
|
||||||
if (isBottomListSheetExpanded) {
|
|
||||||
// Make camera to follow user on location change
|
|
||||||
if (ViewUtil.isPortrait(getActivity())) {
|
|
||||||
position = new CameraPosition.Builder()
|
|
||||||
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
|
|
||||||
curLatLng.getLongitude())) // Sets the new camera target above
|
|
||||||
// current to make it visible when sheet is expanded
|
|
||||||
.zoom(11) // Fixed zoom level
|
|
||||||
.build();
|
|
||||||
} else {
|
|
||||||
position = new CameraPosition.Builder()
|
|
||||||
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
|
|
||||||
curLatLng.getLongitude())) // Sets the new camera target above
|
|
||||||
// current to make it visible when sheet is expanded
|
|
||||||
.zoom(11) // Fixed zoom level
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Make camera to follow user on location change
|
|
||||||
position = new CameraPosition.Builder()
|
|
||||||
.target(new LatLng(curLatLng.getLatitude(),
|
|
||||||
curLatLng.getLongitude())) // Sets the new camera target to curLatLng
|
|
||||||
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
mapboxMap.animateCamera(CameraUpdateFactory
|
|
||||||
.newCameraPosition(position), 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
Timber.d("initViews called");
|
Timber.d("initViews called");
|
||||||
bottomSheetList = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.bottom_sheet);
|
bottomSheetList = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.bottom_sheet);
|
||||||
|
|
@ -446,7 +407,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
curLatLng.getLongitude())
|
curLatLng.getLongitude())
|
||||||
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
||||||
.zoom(isBottomListSheetExpanded ?
|
.zoom(isBottomListSheetExpanded ?
|
||||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
ZOOM_LEVEL
|
||||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||||
.build();
|
.build();
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -456,7 +417,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
curLatLng.getLongitude())
|
curLatLng.getLongitude())
|
||||||
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
||||||
.zoom(isBottomListSheetExpanded ?
|
.zoom(isBottomListSheetExpanded ?
|
||||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
ZOOM_LEVEL
|
||||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
@ -494,9 +455,6 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||||
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
|
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
updateMapCameraAccordingToBottomSheet(true);
|
|
||||||
} else {
|
|
||||||
updateMapCameraAccordingToBottomSheet(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -526,7 +484,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
.attributionEnabled(false)
|
.attributionEnabled(false)
|
||||||
.camera(new CameraPosition.Builder()
|
.camera(new CameraPosition.Builder()
|
||||||
.target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()))
|
.target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()))
|
||||||
.zoom(11)
|
.zoom(ZOOM_LEVEL)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
if (!getParentFragment().getActivity().isFinishing()) {
|
if (!getParentFragment().getActivity().isFinishing()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue