[android] - fix reset behavior for setLatLngBoundsForCameraTarget
This commit is contained in:
@@ -63,7 +63,7 @@ interface NativeMap {
|
||||
|
||||
LatLng getLatLng();
|
||||
|
||||
void setLatLngBounds(@NonNull LatLngBounds latLngBounds);
|
||||
void setLatLngBounds(@Nullable LatLngBounds latLngBounds);
|
||||
|
||||
void setVisibleCoordinateBounds(@NonNull LatLng[] coordinates, @NonNull RectF padding,
|
||||
double direction, long duration);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
@@ -76,25 +77,30 @@ public class LatLngBoundsForCameraActivity extends AppCompatActivity implements
|
||||
case R.id.menu_action_cross_idl:
|
||||
setupBounds(CROSS_IDL_BOUNDS);
|
||||
return true;
|
||||
case R.id.menu_action_reset:
|
||||
setupBounds(null);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setupBounds(LatLngBounds bounds) {
|
||||
private void setupBounds(@Nullable LatLngBounds bounds) {
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(bounds);
|
||||
showBoundsArea(bounds);
|
||||
}
|
||||
|
||||
private void showBoundsArea(LatLngBounds bounds) {
|
||||
private void showBoundsArea(@Nullable LatLngBounds bounds) {
|
||||
mapboxMap.clear();
|
||||
PolygonOptions boundsArea = new PolygonOptions()
|
||||
.add(bounds.getNorthWest())
|
||||
.add(bounds.getNorthEast())
|
||||
.add(bounds.getSouthEast())
|
||||
.add(bounds.getSouthWest());
|
||||
boundsArea.alpha(0.25f);
|
||||
boundsArea.fillColor(Color.RED);
|
||||
mapboxMap.addPolygon(boundsArea);
|
||||
if (bounds != null) {
|
||||
PolygonOptions boundsArea = new PolygonOptions()
|
||||
.add(bounds.getNorthWest())
|
||||
.add(bounds.getNorthEast())
|
||||
.add(bounds.getSouthEast())
|
||||
.add(bounds.getSouthWest());
|
||||
boundsArea.alpha(0.25f);
|
||||
boundsArea.fillColor(Color.RED);
|
||||
mapboxMap.addPolygon(boundsArea);
|
||||
}
|
||||
}
|
||||
|
||||
private void showCrosshair() {
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
android:id="@+id/menu_action_cross_idl"
|
||||
android:title="@string/restrict_across_idl"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_action_reset"
|
||||
android:title="@string/restrict_reset"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
||||
@@ -90,4 +90,5 @@
|
||||
<string name="zoom_to_4">Zoom to 4</string>
|
||||
<string name="restrict_almost_worldview">Restrict almost worldview</string>
|
||||
<string name="restrict_across_idl">Restrict across IDL</string>
|
||||
<string name="restrict_reset">Reset bounds</string>
|
||||
</resources>
|
||||
@@ -314,7 +314,7 @@ void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::Object<mbgl::an
|
||||
if (jBounds) {
|
||||
bounds.withLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
|
||||
} else {
|
||||
bounds.withLatLngBounds(mbgl::LatLngBounds::world());
|
||||
bounds.withLatLngBounds(mbgl::LatLngBounds::unbounded());
|
||||
}
|
||||
map->setBounds(bounds);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user