@@ -135,6 +135,8 @@ public class NearbyMapFragment extends DaggerFragment {
135135 @ Inject
136136 BookmarkLocationsDao bookmarkLocationDao ;
137137
138+ private static final double ZOOM_LEVEL = 14f ;
139+
138140 public NearbyMapFragment () {
139141 }
140142
@@ -304,7 +306,7 @@ private void updateMapToTrackPosition() {
304306 curMapBoxLatLng .getLongitude ())
305307 : curMapBoxLatLng ) // Sets the new camera position
306308 .zoom (isBottomListSheetExpanded ?
307- 11 // zoom level is fixed to 11 when bottom sheet is expanded
309+ ZOOM_LEVEL // zoom level is fixed when bottom sheet is expanded
308310 :mapboxMap .getCameraPosition ().zoom ) // Same zoom level
309311 .build ();
310312 }else {
@@ -314,7 +316,7 @@ private void updateMapToTrackPosition() {
314316 curMapBoxLatLng .getLongitude ())
315317 : curMapBoxLatLng ) // Sets the new camera position
316318 .zoom (isBottomListSheetExpanded ?
317- 11 // zoom level is fixed to 11 when bottom sheet is expanded
319+ ZOOM_LEVEL // zoom level is fixed when bottom sheet is expanded
318320 :mapboxMap .getCameraPosition ().zoom ) // Same zoom level
319321 .build ();
320322 }
@@ -325,47 +327,6 @@ private void updateMapToTrackPosition() {
325327 }
326328 }
327329
328- /**
329- * Updates camera position according to list sheet status. If list sheet is collapsed, camera
330- * focus should be in the center. If list sheet is expanded, camera focus should be visible
331- * on the gap between list sheet and tab layout.
332- * @param isBottomListSheetExpanded
333- */
334- private void updateMapCameraAccordingToBottomSheet (boolean isBottomListSheetExpanded ) {
335- CameraPosition position ;
336- this .isBottomListSheetExpanded = isBottomListSheetExpanded ;
337- if (mapboxMap != null && curLatLng != null ) {
338- if (isBottomListSheetExpanded ) {
339- // Make camera to follow user on location change
340- if (ViewUtil .isPortrait (getActivity ())) {
341- position = new CameraPosition .Builder ()
342- .target (new LatLng (curLatLng .getLatitude () - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT ,
343- curLatLng .getLongitude ())) // Sets the new camera target above
344- // current to make it visible when sheet is expanded
345- .zoom (11 ) // Fixed zoom level
346- .build ();
347- } else {
348- position = new CameraPosition .Builder ()
349- .target (new LatLng (curLatLng .getLatitude () - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE ,
350- curLatLng .getLongitude ())) // Sets the new camera target above
351- // current to make it visible when sheet is expanded
352- .zoom (11 ) // Fixed zoom level
353- .build ();
354- }
355-
356- } else {
357- // Make camera to follow user on location change
358- position = new CameraPosition .Builder ()
359- .target (new LatLng (curLatLng .getLatitude (),
360- curLatLng .getLongitude ())) // Sets the new camera target to curLatLng
361- .zoom (mapboxMap .getCameraPosition ().zoom ) // Same zoom level
362- .build ();
363- }
364- mapboxMap .animateCamera (CameraUpdateFactory
365- .newCameraPosition (position ), 1000 );
366- }
367- }
368-
369330 private void initViews () {
370331 Timber .d ("initViews called" );
371332 bottomSheetList = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .bottom_sheet );
@@ -446,7 +407,7 @@ private void setListeners() {
446407 curLatLng .getLongitude ())
447408 : new LatLng (curLatLng .getLatitude (), curLatLng .getLongitude (), 0 )) // Sets the new camera position
448409 .zoom (isBottomListSheetExpanded ?
449- 11 // zoom level is fixed to 11 when bottom sheet is expanded
410+ ZOOM_LEVEL
450411 :mapboxMap .getCameraPosition ().zoom ) // Same zoom level
451412 .build ();
452413 }else {
@@ -456,7 +417,7 @@ private void setListeners() {
456417 curLatLng .getLongitude ())
457418 : new LatLng (curLatLng .getLatitude (), curLatLng .getLongitude (), 0 )) // Sets the new camera position
458419 .zoom (isBottomListSheetExpanded ?
459- 11 // zoom level is fixed to 11 when bottom sheet is expanded
420+ ZOOM_LEVEL
460421 :mapboxMap .getCameraPosition ().zoom ) // Same zoom level
461422 .build ();
462423 }
@@ -494,9 +455,6 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) {
494455 public void onStateChanged (@ NonNull View bottomSheet , int newState ) {
495456 if (newState == BottomSheetBehavior .STATE_EXPANDED ) {
496457 bottomSheetDetailsBehavior .setState (BottomSheetBehavior .STATE_HIDDEN );
497- updateMapCameraAccordingToBottomSheet (true );
498- } else {
499- updateMapCameraAccordingToBottomSheet (false );
500458 }
501459 }
502460
@@ -526,7 +484,7 @@ private void setupMapView(Bundle savedInstanceState) {
526484 .attributionEnabled (false )
527485 .camera (new CameraPosition .Builder ()
528486 .target (new LatLng (curLatLng .getLatitude (), curLatLng .getLongitude ()))
529- .zoom (11 )
487+ .zoom (ZOOM_LEVEL )
530488 .build ());
531489
532490 if (!getParentFragment ().getActivity ().isFinishing ()) {
0 commit comments