Skip to content

Commit 1c47024

Browse files
neslihanturanmaskaravivek
authored andcommitted
Fix multiple current location marker issue (commons-app#3243)
1 parent 21503fc commit 1c47024

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyMapFragment.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public void updateMapToTrackPosition(LatLng curLatLng) {
315315
*/
316316
@Override
317317
public void addCurrentLocationMarker(LatLng curLatLng) {
318+
removeCurrentLocationMarker();
318319
Timber.d("Adds current location marker");
319320

320321
Icon icon = IconFactory.getInstance(getContext()).fromResource(R.drawable.current_location_marker);
@@ -336,8 +337,10 @@ public void addCurrentLocationMarker(LatLng curLatLng) {
336337

337338
@Override
338339
public void removeCurrentLocationMarker() {
339-
mapboxMap.removeMarker(currentLocationMarker);
340-
mapboxMap.removePolygon(currentLocationPolygon);
340+
if (currentLocationMarker != null) {
341+
mapboxMap.removeMarker(currentLocationMarker);
342+
mapboxMap.removePolygon(currentLocationPolygon);
343+
}
341344
}
342345

343346
/**

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,6 @@ public void enableFABRecenter() {
842842

843843
@Override
844844
public void recenterMap(fr.free.nrw.commons.location.LatLng curLatLng) {
845-
nearbyMapFragment.removeCurrentLocationMarker();
846845
nearbyMapFragment.addCurrentLocationMarker(curLatLng);
847846
CameraPosition position;
848847

0 commit comments

Comments
 (0)