[android] #4318 - move min/max zoom level to MapboxMap
This commit is contained in:
@@ -15,7 +15,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ApiAccess;
|
||||
|
||||
public class MaxMinZoomActivity extends AppCompatActivity {
|
||||
@@ -45,10 +44,8 @@ public class MaxMinZoomActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
mMapboxMap = mapboxMap;
|
||||
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
uiSettings.setMinZoom(3);
|
||||
uiSettings.setMaxZoom(5);
|
||||
mMapboxMap.setMinZoom(3);
|
||||
mMapboxMap.setMaxZoom(5);
|
||||
|
||||
mMapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-1.063510, 32.895425)));
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class OfflineActivity extends AppCompatActivity
|
||||
String styleURL = mMapboxMap.getStyleUrl();
|
||||
LatLngBounds bounds = mMapboxMap.getProjection().getVisibleRegion().latLngBounds;
|
||||
double minZoom = mMapboxMap.getCameraPosition().zoom;
|
||||
double maxZoom = mMapboxMap.getUiSettings().getMaxZoom();
|
||||
double maxZoom = mMapboxMap.getMaxZoom();
|
||||
float pixelRatio = this.getResources().getDisplayMetrics().density;
|
||||
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
|
||||
styleURL, bounds, minZoom, maxZoom, pixelRatio);
|
||||
@@ -346,6 +346,7 @@ public class OfflineActivity extends AppCompatActivity
|
||||
mProgressBar.setIndeterminate(true);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setPercentage(final int percentage) {
|
||||
mProgressBar.setIndeterminate(false);
|
||||
mProgressBar.setProgress(percentage);
|
||||
|
||||
@@ -10,9 +10,7 @@ import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -26,11 +24,9 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.matches;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -108,6 +104,30 @@ public class MapboxMapTest {
|
||||
assertNotNull("UiSettings should not be null", mMapboxMap.getUiSettings());
|
||||
}
|
||||
|
||||
//
|
||||
// MinZoomLevel
|
||||
//
|
||||
|
||||
@Test
|
||||
public void testMinZoom() {
|
||||
double zoom = 10;
|
||||
mMapboxMap.setMinZoom(zoom);
|
||||
assertEquals("MinZoom should match", zoom, mMapboxMap.getMinZoom(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxZoom() {
|
||||
double zoom = 10;
|
||||
mMapboxMap.setMaxZoom(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, mMapboxMap.getMaxZoom(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialZoomLevels() {
|
||||
assertEquals("MaxZoom should match", 0, mMapboxMap.getMaxZoom(), 0);
|
||||
assertEquals("MinZoom should match", 0, mMapboxMap.getMinZoom(), 0);
|
||||
}
|
||||
|
||||
//
|
||||
// TrackingSettings
|
||||
//
|
||||
@@ -221,15 +241,15 @@ public class MapboxMapTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnBearingTrackingModeChangeListener(){
|
||||
public void testOnBearingTrackingModeChangeListener() {
|
||||
mMapboxMap.setOnMyBearingTrackingModeChangeListener(mMyBearingTrackingModeChangeListener);
|
||||
assertEquals("MyBearingTrackingChangeListerner should match",mMyBearingTrackingModeChangeListener, mMapboxMap.getOnMyBearingTrackingModeChangeListener());
|
||||
assertEquals("MyBearingTrackingChangeListerner should match", mMyBearingTrackingModeChangeListener, mMapboxMap.getOnMyBearingTrackingModeChangeListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnLocationTrackingModeChangeListener(){
|
||||
public void testOnLocationTrackingModeChangeListener() {
|
||||
mMapboxMap.setOnMyLocationTrackingModeChangeListener(mMyLocationTrackingModeChangeListener);
|
||||
assertEquals("MyLocationTrackigChangeListener should match",mMyLocationTrackingModeChangeListener, mMapboxMap.getOnMyLocationTrackingModeChangeListener());
|
||||
assertEquals("MyLocationTrackigChangeListener should match", mMyLocationTrackingModeChangeListener, mMapboxMap.getOnMyLocationTrackingModeChangeListener());
|
||||
}
|
||||
|
||||
//
|
||||
@@ -709,7 +729,6 @@ public class MapboxMapTest {
|
||||
assertTrue("Selected markers should be empty", mMapboxMap.getSelectedMarkers().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// OnMarkerClick interface
|
||||
//
|
||||
|
||||
@@ -21,30 +21,6 @@ public class UiSettingsTest {
|
||||
assertNotNull("uiSettings should not be null", uiSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinZoom() {
|
||||
double zoom = 10;
|
||||
UiSettings uiSettings = new UiSettings(mMapView);
|
||||
uiSettings.setMinZoom(zoom);
|
||||
assertEquals("MinZoom should match", zoom, uiSettings.getMinZoom(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxZoom() {
|
||||
double zoom = 10;
|
||||
UiSettings uiSettings = new UiSettings(mMapView);
|
||||
uiSettings.setMaxZoom(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, uiSettings.getMaxZoom(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialZoomLevels() {
|
||||
//we are mocking MapView we expect a value of 0 to be returned
|
||||
UiSettings uiSettings = new UiSettings(mMapView);
|
||||
assertEquals("MaxZoom should match", 0, uiSettings.getMaxZoom(), 0);
|
||||
assertEquals("MinZoom should match", 0, uiSettings.getMinZoom(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassEnabled() {
|
||||
UiSettings uiSettings = new UiSettings(mMapView);
|
||||
|
||||
Reference in New Issue
Block a user