So, I created a solution that should be fine. If the user places a card on the -180/180 border, the card will flip over to the other side. So packaging the card is still possible, but the “dangerous” area is never displayed.
I had to create a custom MapView:
public class CustomMapView extends MapView { private double prevLongitude; @Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean retVal = correctCamera(); prevLongitude = getMap().getCameraPosition().target.longitude; return retVal; } public boolean correctCamera() { if (getMap().getProjection().getVisibleRegion().latLngBounds.northeast.longitude < getMap().getProjection().getVisibleRegion().latLngBounds.southwest.longitude) { double diff = getMap().getProjection().getVisibleRegion().latLngBounds.southwest.longitude - getMap().getProjection().getVisibleRegion().latLngBounds.northeast.longitude; double longitudeSW; double longitudeNE; double longitudeDiff = (360-diff) / 25;
And xml:
<com.ieffects.clustermap.CustomMapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" />
And for GoogleMap (mapView.getMap ()):
map.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { mapView.correctCamera(); } });
This is necessary if the user allowed the card to "fly" to a dangerous area.
source share