|
50 | 50 | import com.mapbox.mapboxsdk.camera.CameraPosition; |
51 | 51 | import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; |
52 | 52 | import com.mapbox.mapboxsdk.geometry.LatLng; |
| 53 | +import com.mapbox.mapboxsdk.geometry.LatLngBounds; |
53 | 54 | import com.mapbox.mapboxsdk.maps.MapView; |
54 | 55 | import com.mapbox.mapboxsdk.maps.MapboxMap; |
55 | 56 | import com.mapbox.mapboxsdk.maps.Style; |
@@ -201,6 +202,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment |
201 | 202 | private boolean isVisibleToUser; |
202 | 203 | private MapboxMap.OnCameraMoveListener cameraMoveListener; |
203 | 204 | private fr.free.nrw.commons.location.LatLng lastFocusLocation; |
| 205 | + private LatLngBounds latLngBounds; |
204 | 206 |
|
205 | 207 |
|
206 | 208 | @Override |
@@ -632,6 +634,22 @@ public LatLng getLastFocusLocation() { |
632 | 634 | return lastFocusLocation==null?null:LocationUtils.commonsLatLngToMapBoxLatLng(lastFocusLocation); |
633 | 635 | } |
634 | 636 |
|
| 637 | + @Override |
| 638 | + public boolean isCurrentLocationMarkerVisible() { |
| 639 | + if (latLngBounds == null) { |
| 640 | + Timber.d("Map projection bounds are null"); |
| 641 | + return false; |
| 642 | + } else { |
| 643 | + Timber.d("Current location marker %s" , latLngBounds.contains(currentLocationMarker.getPosition()) ? "visible" : "invisible"); |
| 644 | + return latLngBounds.contains(currentLocationMarker.getPosition()); |
| 645 | + } |
| 646 | + } |
| 647 | + |
| 648 | + @Override |
| 649 | + public void setProjectorLatLngBounds() { |
| 650 | + latLngBounds = mapBox.getProjection().getVisibleRegion().latLngBounds; |
| 651 | + } |
| 652 | + |
635 | 653 | @Override |
636 | 654 | public boolean isNetworkConnectionEstablished() { |
637 | 655 | return NetworkUtils.isInternetConnectionEstablished(getActivity()); |
@@ -906,9 +924,8 @@ public void displayLoginSkippedWarning() { |
906 | 924 | } |
907 | 925 |
|
908 | 926 | private void handleLocationUpdate(fr.free.nrw.commons.location.LatLng latLng, LocationServiceManager.LocationChangeType locationChangeType){ |
909 | | - setMapBoxPosition(latLng); |
910 | | - this.lastKnownLocation=latLng; |
911 | | - NearbyController.currentLocation=lastKnownLocation; |
| 927 | + this.lastKnownLocation = latLng; |
| 928 | + NearbyController.currentLocation = lastKnownLocation; |
912 | 929 | presenter.updateMapAndList(locationChangeType); |
913 | 930 | } |
914 | 931 |
|
@@ -941,14 +958,6 @@ public void onLocationChangedMedium(fr.free.nrw.commons.location.LatLng latLng) |
941 | 958 | } |
942 | 959 | } |
943 | 960 |
|
944 | | - void setMapBoxPosition(fr.free.nrw.commons.location.LatLng latLng){ |
945 | | - CameraPosition position = new CameraPosition.Builder() |
946 | | - .target(LocationUtils.commonsLatLngToMapBoxLatLng(latLng)) // Sets the new camera position |
947 | | - .zoom(ZOOM_LEVEL) // Same zoom level |
948 | | - .build(); |
949 | | - mapBox.moveCamera(CameraUpdateFactory.newCameraPosition(position)); |
950 | | - } |
951 | | - |
952 | 961 | public void backButtonClicked() { |
953 | 962 | presenter.backButtonClicked(); |
954 | 963 | } |
|
0 commit comments