-
-
Notifications
You must be signed in to change notification settings - Fork 847
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #718 from mfazekas/fix-marker-view2
Fix MarkerView resize issue
- Loading branch information
Showing
4 changed files
with
83 additions
and
37 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/MarkerView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mapbox.rctmgl.components.annotation; | ||
|
||
import android.view.View; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
|
||
/** | ||
* Subclass of MarkerView so we MarkerViewManager can implement remove/restoreViews | ||
*/ | ||
public class MarkerView extends com.mapbox.mapboxsdk.plugins.markerview.MarkerView { | ||
View view; | ||
|
||
public MarkerView(@NonNull LatLng latLng, @NonNull View view) { | ||
super(latLng, view); | ||
this.view = view; | ||
} | ||
|
||
public View getView() { | ||
return this.view; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/MarkerViewManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.mapbox.rctmgl.components.annotation; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.mapbox.mapboxsdk.maps.MapView; | ||
import com.mapbox.mapboxsdk.maps.MapboxMap; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Subclass of MarkerViewManager implementing removeViews and restoreViews | ||
*/ | ||
public class MarkerViewManager extends com.mapbox.mapboxsdk.plugins.markerview.MarkerViewManager { | ||
private final List<MarkerView> markers = new ArrayList<>(); | ||
private MapView mapView; | ||
|
||
public MarkerViewManager(MapView mapView, MapboxMap mapboxMap) { | ||
super(mapView, mapboxMap); | ||
this.mapView = mapView; | ||
// this.mapboxMap = mapboxMap; | ||
} | ||
|
||
public void addMarker(@NonNull MarkerView markerView) { | ||
super.addMarker(markerView); | ||
markers.add(markerView); | ||
} | ||
|
||
public void removeMarker(@NonNull MarkerView markerView) { | ||
super.removeMarker(markerView); | ||
markers.remove(markerView); | ||
} | ||
|
||
public void removeViews() { | ||
for (MarkerView marker: markers) { | ||
mapView.removeView(marker.getView()); | ||
} | ||
} | ||
|
||
public void restoreViews() { | ||
for (MarkerView marker: markers) { | ||
mapView.addView(marker.getView()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters