[android] - replace anonymous inner classes with lambda
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
@@ -70,26 +68,24 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testTransitionDuration() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
long transitionDuration = 600;
|
||||
mapboxMap.setTransitionDuration(transitionDuration);
|
||||
assertEquals("TransitionDuration should match", transitionDuration, mapboxMap.getTransitionDuration(), 0);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
long transitionDuration = 600;
|
||||
mapboxMap.setTransitionDuration(transitionDuration);
|
||||
assertEquals(
|
||||
"TransitionDuration should match", transitionDuration, mapboxMap.getTransitionDuration(), 0
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransitionDelay() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
long transitionDelay = 50;
|
||||
mapboxMap.setTransitionDelay(transitionDelay);
|
||||
assertEquals("TransitionDelay should match", transitionDelay, mapboxMap.getTransitionDelay(), 0);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
long transitionDelay = 50;
|
||||
mapboxMap.setTransitionDelay(transitionDelay);
|
||||
assertEquals(
|
||||
"TransitionDelay should match", transitionDelay, mapboxMap.getTransitionDelay(), 0
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -99,40 +95,34 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testCameraPositionOnFinish() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
|
||||
final LatLng latLng = new LatLng(30.0, 30.0);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(latLng), new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
final LatLng latLng = new LatLng(30.0, 30.0);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(latLng), new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
LatLng cameraPositionLatLng = mapboxMap.getCameraPosition().target;
|
||||
Timber.d(cameraPositionLatLng.toString());
|
||||
assertEquals(cameraPositionLatLng.getLatitude(), latLng.getLatitude(), LAT_LNG_DELTA);
|
||||
assertEquals(cameraPositionLatLng.getLongitude(), latLng.getLongitude(), LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onFinish() {
|
||||
LatLng cameraPositionLatLng = mapboxMap.getCameraPosition().target;
|
||||
Timber.d(cameraPositionLatLng.toString());
|
||||
assertEquals(cameraPositionLatLng.getLatitude(), latLng.getLatitude(), LAT_LNG_DELTA);
|
||||
assertEquals(cameraPositionLatLng.getLongitude(), latLng.getLongitude(), LAT_LNG_DELTA);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCameraForLatLngBounds() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
// set
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(
|
||||
new LatLngBounds.Builder().include(new LatLng()).include(new LatLng(1, 1)).build());
|
||||
// reset
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(null);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
// set
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(
|
||||
new LatLngBounds.Builder().include(new LatLng()).include(new LatLng(1, 1)).build());
|
||||
// reset
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(null);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -143,12 +133,9 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testMinZoom() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMinZoomPreference(10);
|
||||
assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMinZoomPreference(10);
|
||||
assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -156,12 +143,9 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
public void testMaxZoom() {
|
||||
validateTestSetup();
|
||||
final double zoom = 10;
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMaxZoomPreference(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMaxZoomPreference(zoom);
|
||||
assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -169,14 +153,11 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testInitialZoomLevels() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(),
|
||||
TestConstants.ZOOM_DELTA);
|
||||
assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(),
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(),
|
||||
TestConstants.ZOOM_DELTA);
|
||||
assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(),
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -197,43 +178,28 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testConcurrentInfoWindowEnabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcurrentInfoWindowDisabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false);
|
||||
assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false);
|
||||
assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoWindowAdapter() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MapboxMap.InfoWindowAdapter infoWindowAdapter = new MapboxMap.InfoWindowAdapter() {
|
||||
@Nullable
|
||||
@Override
|
||||
public View getInfoWindow(@NonNull Marker marker) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
mapboxMap.setInfoWindowAdapter(infoWindowAdapter);
|
||||
assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MapboxMap.InfoWindowAdapter infoWindowAdapter = marker -> null;
|
||||
mapboxMap.setInfoWindowAdapter(infoWindowAdapter);
|
||||
assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -245,12 +211,9 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Ignore /* disabled due to enabling permissions during test #7177 */
|
||||
public void testMyLocationEnabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -258,12 +221,9 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Ignore /* can't create handler inside thread that not called Looper.prepare() */
|
||||
public void testMyLocationDisabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setMyLocationEnabled(false);
|
||||
assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMyLocationEnabled(false);
|
||||
assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -274,73 +234,49 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testFpsListener() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MapboxMap.OnFpsChangedListener fpsChangedListener = new MapboxMap.OnFpsChangedListener() {
|
||||
@Override
|
||||
public void onFpsChanged(double fps) {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MapboxMap.OnFpsChangedListener fpsChangedListener = fps -> {
|
||||
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnFpsChangedListener(fpsChangedListener);
|
||||
assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener());
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnFpsChangedListener(fpsChangedListener);
|
||||
assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoWindowClickListener() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MapboxMap.OnInfoWindowClickListener clickListener = new MapboxMap.OnInfoWindowClickListener() {
|
||||
@Override
|
||||
public boolean onInfoWindowClick(@NonNull Marker marker) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnInfoWindowClickListener(clickListener);
|
||||
assertEquals("InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MapboxMap.OnInfoWindowClickListener clickListener = marker -> false;
|
||||
mapboxMap.setOnInfoWindowClickListener(clickListener);
|
||||
assertEquals(
|
||||
"InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener()
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoWindowCloseListener() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MapboxMap.OnInfoWindowCloseListener listener = new MapboxMap.OnInfoWindowCloseListener() {
|
||||
@Override
|
||||
public void onInfoWindowClose(Marker marker) {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MapboxMap.OnInfoWindowCloseListener listener = marker -> {
|
||||
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnInfoWindowCloseListener(listener);
|
||||
assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener());
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnInfoWindowCloseListener(listener);
|
||||
assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoWindowLongClickListener() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MapboxMap.OnInfoWindowLongClickListener listener = new MapboxMap.OnInfoWindowLongClickListener() {
|
||||
@Override
|
||||
public void onInfoWindowLongClick(Marker marker) {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MapboxMap.OnInfoWindowLongClickListener listener = marker -> {
|
||||
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnInfoWindowLongClickListener(listener);
|
||||
assertEquals("InfoWindowLongClickListener should match", listener,
|
||||
mapboxMap.getOnInfoWindowLongClickListener());
|
||||
}
|
||||
};
|
||||
mapboxMap.setOnInfoWindowLongClickListener(listener);
|
||||
assertEquals("InfoWindowLongClickListener should match", listener,
|
||||
mapboxMap.getOnInfoWindowLongClickListener());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -351,13 +287,10 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAddMarker() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -369,442 +302,356 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAddMarkers() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size());
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(1)));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size());
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(1)));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMarkersEmpty() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMarkersSingleMarker() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
|
||||
markerList.add(markerOptions);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size());
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
|
||||
markerList.add(markerOptions);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size());
|
||||
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolygon() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEmptyPolygon() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolygonOptions polygonOptions = new PolygonOptions();
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolygonOptions polygonOptions = new PolygonOptions();
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolygons() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<PolygonOptions> polygonList = new ArrayList<>();
|
||||
PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
|
||||
PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
|
||||
PolygonOptions polygonOptions3 = new PolygonOptions();
|
||||
polygonList.add(polygonOptions1);
|
||||
polygonList.add(polygonOptions2);
|
||||
polygonList.add(polygonOptions3);
|
||||
mapboxMap.addPolygons(polygonList);
|
||||
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size());
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon()));
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon()));
|
||||
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon()));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<PolygonOptions> polygonList = new ArrayList<>();
|
||||
PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
|
||||
PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
|
||||
PolygonOptions polygonOptions3 = new PolygonOptions();
|
||||
polygonList.add(polygonOptions1);
|
||||
polygonList.add(polygonOptions2);
|
||||
polygonList.add(polygonOptions3);
|
||||
mapboxMap.addPolygons(polygonList);
|
||||
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size());
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon()));
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon()));
|
||||
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon()));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPolygonsEmpty() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.addPolygons(new ArrayList<PolygonOptions>());
|
||||
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.addPolygons(new ArrayList<PolygonOptions>());
|
||||
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPolygonsSingle() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<PolygonOptions> polygonList = new ArrayList<>();
|
||||
PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
|
||||
polygonList.add(polygonOptions);
|
||||
mapboxMap.addPolygons(polygonList);
|
||||
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon()));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<PolygonOptions> polygonList = new ArrayList<>();
|
||||
PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
|
||||
polygonList.add(polygonOptions);
|
||||
mapboxMap.addPolygons(polygonList);
|
||||
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon()));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolyline() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEmptyPolyline() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolylines() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<PolylineOptions> polylineList = new ArrayList<>();
|
||||
PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
|
||||
PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
|
||||
PolylineOptions polygonOptions3 = new PolylineOptions();
|
||||
polylineList.add(polygonOptions1);
|
||||
polylineList.add(polygonOptions2);
|
||||
polylineList.add(polygonOptions3);
|
||||
mapboxMap.addPolylines(polylineList);
|
||||
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size());
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline()));
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline()));
|
||||
assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline()));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<PolylineOptions> polylineList = new ArrayList<>();
|
||||
PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
|
||||
PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
|
||||
PolylineOptions polygonOptions3 = new PolylineOptions();
|
||||
polylineList.add(polygonOptions1);
|
||||
polylineList.add(polygonOptions2);
|
||||
polylineList.add(polygonOptions3);
|
||||
mapboxMap.addPolylines(polylineList);
|
||||
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size());
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline()));
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline()));
|
||||
assertTrue(
|
||||
"Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline())
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolylinesEmpty() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.addPolylines(new ArrayList<PolylineOptions>());
|
||||
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.addPolylines(new ArrayList<PolylineOptions>());
|
||||
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPolylinesSingle() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<PolylineOptions> polylineList = new ArrayList<>();
|
||||
PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
|
||||
polylineList.add(polygonOptions);
|
||||
mapboxMap.addPolylines(polylineList);
|
||||
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline()));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<PolylineOptions> polylineList = new ArrayList<>();
|
||||
PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
|
||||
polylineList.add(polygonOptions);
|
||||
mapboxMap.addPolylines(polylineList);
|
||||
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline()));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveMarker() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.removeMarker(marker);
|
||||
assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.removeMarker(marker);
|
||||
assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovePolygon() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolygonOptions polygonOptions = new PolygonOptions();
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
mapboxMap.removePolygon(polygon);
|
||||
assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolygonOptions polygonOptions = new PolygonOptions();
|
||||
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
|
||||
mapboxMap.removePolygon(polygon);
|
||||
assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovePolyline() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
mapboxMap.removePolyline(polyline);
|
||||
assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
|
||||
mapboxMap.removePolyline(polyline);
|
||||
assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAnnotation() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.removeAnnotation(marker);
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.removeAnnotation(marker);
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAnnotationById() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
mapboxMap.addMarker(markerOptions);
|
||||
// id will always be 0 in unit tests
|
||||
mapboxMap.removeAnnotation(0);
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
mapboxMap.addMarker(markerOptions);
|
||||
// id will always be 0 in unit tests
|
||||
mapboxMap.removeAnnotation(0);
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAnnotations() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
mapboxMap.removeAnnotations();
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
mapboxMap.removeAnnotations();
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
mapboxMap.clear();
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
mapboxMap.clear();
|
||||
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAnnotationsByList() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
|
||||
mapboxMap.removeAnnotations(markers);
|
||||
assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1);
|
||||
assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
List<BaseMarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
List<Marker> markers = mapboxMap.addMarkers(markerList);
|
||||
Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
|
||||
mapboxMap.removeAnnotations(markers);
|
||||
assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1);
|
||||
assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAnnotationById() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker initialMarker = mapboxMap.addMarker(markerOptions);
|
||||
Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0);
|
||||
assertEquals("Markers should match", initialMarker, retrievedMarker);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker initialMarker = mapboxMap.addMarker(markerOptions);
|
||||
Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0);
|
||||
assertEquals("Markers should match", initialMarker, retrievedMarker);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAnnotations() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertNotNull("Annotations should be non null", mapboxMap.getAnnotations());
|
||||
}
|
||||
}));
|
||||
onView(withId(R.id.mapView)).perform(
|
||||
new MapboxMapAction((uiController, view) ->
|
||||
assertNotNull("Annotations should be non null", mapboxMap.getAnnotations()))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMarkers() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertNotNull("Markers should be non null", mapboxMap.getMarkers());
|
||||
}
|
||||
}));
|
||||
onView(withId(R.id.mapView)).perform(
|
||||
new MapboxMapAction((uiController, view) ->
|
||||
assertNotNull("Markers should be non null", mapboxMap.getMarkers()))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPolygons() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertNotNull("Polygons should be non null", mapboxMap.getPolygons());
|
||||
}
|
||||
}));
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
|
||||
assertNotNull("Polygons should be non null", mapboxMap.getPolygons()))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPolylines() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertNotNull("Polylines should be non null", mapboxMap.getPolylines());
|
||||
}
|
||||
}));
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
|
||||
assertNotNull("Polylines should be non null", mapboxMap.getPolylines()))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSelectedMarkers() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers());
|
||||
}
|
||||
}));
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
|
||||
assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers()))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectMarker() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker);
|
||||
assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker));
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker);
|
||||
assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker));
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeselectMarker() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker);
|
||||
mapboxMap.deselectMarker(marker);
|
||||
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker);
|
||||
mapboxMap.deselectMarker(marker);
|
||||
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeselectMarkers() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker1 = mapboxMap.addMarker(markerOptions);
|
||||
Marker marker2 = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker1);
|
||||
mapboxMap.selectMarker(marker2);
|
||||
mapboxMap.deselectMarkers();
|
||||
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
|
||||
Marker marker1 = mapboxMap.addMarker(markerOptions);
|
||||
Marker marker2 = mapboxMap.addMarker(markerOptions);
|
||||
mapboxMap.selectMarker(marker1);
|
||||
mapboxMap.selectMarker(marker2);
|
||||
mapboxMap.deselectMarkers();
|
||||
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -813,14 +660,11 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testTilePrefetch() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
mapboxMap.setPrefetchesTiles(true);
|
||||
assertTrue(mapboxMap.getPrefetchesTiles());
|
||||
mapboxMap.setPrefetchesTiles(false);
|
||||
assertFalse(mapboxMap.getPrefetchesTiles());
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setPrefetchesTiles(true);
|
||||
assertTrue(mapboxMap.getPrefetchesTiles());
|
||||
mapboxMap.setPrefetchesTiles(false);
|
||||
assertFalse(mapboxMap.getPrefetchesTiles());
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
@@ -34,25 +31,22 @@ public class MarkerTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void addMarkerTest() {
|
||||
validateTestSetup();
|
||||
MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
|
||||
MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
}
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,16 +54,13 @@ public class MarkerTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
mapboxMap.selectMarker(marker);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
@@ -36,24 +32,21 @@ public class MarkerViewTest extends BaseActivityTest {
|
||||
public void addMarkerViewTest() {
|
||||
validateTestSetup();
|
||||
addAdapter();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
|
||||
TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.position(new LatLng());
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.position(new LatLng());
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
}
|
||||
@@ -63,18 +56,15 @@ public class MarkerViewTest extends BaseActivityTest {
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
addAdapter();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.position(new LatLng());
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.position(new LatLng());
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
mapboxMap.selectMarker(marker);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
@@ -82,13 +72,8 @@ public class MarkerViewTest extends BaseActivityTest {
|
||||
}
|
||||
|
||||
private void addAdapter() {
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
|
||||
new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap));
|
||||
}
|
||||
});
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
|
||||
new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
@@ -28,31 +25,28 @@ public class PolygonTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void addPolygonTest() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
LatLng latLngThree = new LatLng(1, 1);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
LatLng latLngThree = new LatLng(1, 1);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
Polygon polygon = mapboxMap.addPolygon(options);
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
options.fillColor(Color.RED);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
Polygon polygon = mapboxMap.addPolygon(options);
|
||||
|
||||
assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygon id should be 0", 0, polygon.getId());
|
||||
assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
|
||||
assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
|
||||
assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
}
|
||||
assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygon id should be 0", 0, polygon.getId());
|
||||
assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
|
||||
assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
|
||||
assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
@@ -28,27 +25,24 @@ public class PolylineTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void addPolylineTest() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
Polyline polyline = mapboxMap.addPolyline(options);
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
Polyline polyline = mapboxMap.addPolyline(options);
|
||||
|
||||
assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertEquals("Polyline id should be 0", 0, polyline.getId());
|
||||
assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
|
||||
assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
|
||||
}
|
||||
assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertEquals("Polyline id should be 0", 0, polyline.getId());
|
||||
assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
|
||||
assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
@@ -30,23 +27,20 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,20 +48,17 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,32 +66,29 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,27 +96,24 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToBounds() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,21 +121,18 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToMoveBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,16 +140,13 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToZoomIn() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,18 +154,15 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToZoomOut() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,17 +170,14 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToZoomBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,16 +185,13 @@ public class CameraAnimateTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testAnimateToZoomTo() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
@@ -30,23 +27,20 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,20 +48,17 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,32 +66,29 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,27 +96,24 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToBounds() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,21 +121,18 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToMoveBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,16 +140,13 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToZoomIn() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,18 +154,15 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToZoomOut() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,17 +170,14 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToZoomBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,16 +185,13 @@ public class CameraEaseTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testEaseToZoomTo() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
@@ -30,23 +28,20 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToCameraPositionTarget() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(moveTarget));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,20 +49,17 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToCameraPositionTargetZoom() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,32 +67,29 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToCameraPosition() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
final float moveBearing = 12.5f;
|
||||
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(moveTarget)
|
||||
.zoom(moveZoom)
|
||||
.tilt(moveTilt)
|
||||
.bearing(moveBearing)
|
||||
.build())
|
||||
);
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
|
||||
assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
|
||||
assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,27 +97,24 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToBounds() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(cornerOne);
|
||||
builder.include(cornerTwo);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match center bounds",
|
||||
cameraPosition.target.getLatitude(),
|
||||
centerBounds.getLatitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Moved camera position longitude should match center bounds",
|
||||
cameraPosition.target.getLongitude(),
|
||||
centerBounds.getLongitude(),
|
||||
TestConstants.LAT_LNG_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,21 +122,18 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToMoveBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
|
||||
final LatLng moveTarget = new LatLng(2, 2);
|
||||
final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.scrollBy(
|
||||
moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
|
||||
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
|
||||
moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,16 +141,13 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToZoomIn() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomIn());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,18 +155,15 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToZoomOut() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 10.0f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomOut());
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,17 +171,14 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToZoomBy() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(zoomBy));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,16 +186,13 @@ public class CameraMoveTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testMoveToZoomTo() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final float zoomTo = 2.45f;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(zoomTo));
|
||||
uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
|
||||
TestConstants.ZOOM_DELTA);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.mapbox.mapboxsdk.testapp.feature;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.espresso.action.CoordinatesProvider;
|
||||
import android.support.test.espresso.action.GeneralClickAction;
|
||||
import android.support.test.espresso.action.Press;
|
||||
import android.support.test.espresso.action.Tap;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -44,15 +42,12 @@ public class QueryRenderedFeaturesPropertiesTest extends BaseActivityTest {
|
||||
private static ViewAction clickXY(final float x, final float y) {
|
||||
return new GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
new CoordinatesProvider() {
|
||||
@Override
|
||||
public float[] calculateCoordinates(View view) {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[] {screenX, screenY};
|
||||
}
|
||||
view -> {
|
||||
final int[] screenPos = new int[2];
|
||||
view.getLocationOnScreen(screenPos);
|
||||
final float screenX = screenPos[0] + x;
|
||||
final float screenY = screenPos[1] + y;
|
||||
return new float[] {screenX, screenY};
|
||||
},
|
||||
Press.FINGER);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.testapp.geometry;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity;
|
||||
@@ -26,15 +23,12 @@ public class LatLngBoundsTest extends BaseActivityTest {
|
||||
public void testLatLngBounds() {
|
||||
// regression test for #9322
|
||||
validateTestSetup();
|
||||
MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
LatLngBounds bounds = new LatLngBounds.Builder()
|
||||
.include(new LatLng(48.8589506, 2.2773457))
|
||||
.include(new LatLng(47.2383171, -1.6309316))
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
}
|
||||
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
LatLngBounds bounds = new LatLngBounds.Builder()
|
||||
.include(new LatLng(48.8589506, 2.2773457))
|
||||
.include(new LatLng(47.2383171, -1.6309316))
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -150,15 +150,12 @@ public class AttributionTest extends BaseActivityTest {
|
||||
}
|
||||
|
||||
private void buildUrlSpans() {
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
|
||||
@Override
|
||||
public void onViewAction(UiController uiController, View view) {
|
||||
for (Source source : mapboxMap.getSources()) {
|
||||
String attributionSource = source.getAttribution();
|
||||
if (!TextUtils.isEmpty(attributionSource)) {
|
||||
SpannableStringBuilder htmlBuilder = (SpannableStringBuilder) Html.fromHtml(attributionSource);
|
||||
urlSpans = htmlBuilder.getSpans(0, htmlBuilder.length(), URLSpan.class);
|
||||
}
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
for (Source source : mapboxMap.getSources()) {
|
||||
String attributionSource = source.getAttribution();
|
||||
if (!TextUtils.isEmpty(attributionSource)) {
|
||||
SpannableStringBuilder htmlBuilder = (SpannableStringBuilder) Html.fromHtml(attributionSource);
|
||||
urlSpans = htmlBuilder.getSpans(0, htmlBuilder.length(), URLSpan.class);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.testapp.maps.widgets;
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
@@ -41,18 +37,15 @@ public class CompassViewTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testVisible() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
));
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
));
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
});
|
||||
onView(withId(R.id.compassView)).check(matches(isDisplayed()));
|
||||
}
|
||||
@@ -61,27 +54,19 @@ public class CompassViewTest extends BaseActivityTest {
|
||||
@Ignore
|
||||
public void testClick() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
));
|
||||
}
|
||||
});
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
.target(new LatLng())
|
||||
.build()
|
||||
)));
|
||||
onView(withId(R.id.compassView)).perform(click());
|
||||
waitLoop();
|
||||
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,38 +3,34 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
@@ -51,12 +47,7 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
});
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> layer = mapboxMap.getLayerAs("background"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,18 +55,15 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,16 +72,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,15 +87,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,30 +101,27 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,15 +130,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,16 +144,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-patternTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,15 +159,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,29 +173,26 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -234,16 +201,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,15 +216,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -269,30 +230,27 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,8 @@ package com.mapbox.mapboxsdk.testapp.style;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
@@ -34,21 +32,18 @@ public class ImageTest extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAddGetImage() {
|
||||
validateTestSetup();
|
||||
MapboxMapAction.invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
Drawable drawable = rule.getActivity().getResources().getDrawable(R.drawable.ic_launcher_round);
|
||||
assertTrue(drawable instanceof BitmapDrawable);
|
||||
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
Drawable drawable = rule.getActivity().getResources().getDrawable(R.drawable.ic_launcher_round);
|
||||
assertTrue(drawable instanceof BitmapDrawable);
|
||||
|
||||
Bitmap bitmapSet = ((BitmapDrawable) drawable).getBitmap();
|
||||
mapboxMap.addImage(IMAGE_ID, bitmapSet);
|
||||
Bitmap bitmapSet = ((BitmapDrawable) drawable).getBitmap();
|
||||
mapboxMap.addImage(IMAGE_ID, bitmapSet);
|
||||
|
||||
Bitmap bitmapGet = mapboxMap.getImage(IMAGE_ID);
|
||||
assertTrue(bitmapGet.sameAs(bitmapSet));
|
||||
Bitmap bitmapGet = mapboxMap.getImage(IMAGE_ID);
|
||||
assertTrue(bitmapGet.sameAs(bitmapSet));
|
||||
|
||||
mapboxMap.removeImage(IMAGE_ID);
|
||||
assertNull(mapboxMap.getImage(IMAGE_ID));
|
||||
}
|
||||
mapboxMap.removeImage(IMAGE_ID);
|
||||
assertNull(mapboxMap.getImage(IMAGE_ID));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,24 +6,22 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
@@ -33,7 +31,6 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBas
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
|
||||
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
@@ -48,14 +45,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,15 +58,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("positionTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,15 +72,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("position");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,15 +86,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,14 +100,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,15 +113,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("intensityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,14 +127,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("intensity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,39 +2,36 @@
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
@@ -51,17 +48,14 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -71,18 +65,15 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,16 +82,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,15 +97,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,30 +111,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,16 +140,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotateTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,15 +155,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,30 +169,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -225,16 +198,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-minTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -243,15 +213,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -260,30 +227,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -292,16 +256,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-maxTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -310,15 +271,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -327,30 +285,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -359,16 +314,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturationTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -377,15 +329,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -394,30 +343,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -426,16 +372,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrastTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -444,15 +387,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -461,30 +401,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -493,16 +430,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-durationTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterFadeDurationTransition(options);
|
||||
assertEquals(layer.getRasterFadeDurationTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterFadeDurationTransition(options);
|
||||
assertEquals(layer.getRasterFadeDurationTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -511,15 +445,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -528,30 +459,27 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
@@ -22,7 +21,6 @@ import com.mapbox.mapboxsdk.style.sources.RasterSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
|
||||
@@ -192,41 +190,38 @@ public class RuntimeStyleTests extends BaseActivityTest {
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
mapboxMap.removeSource("my-source");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
mapboxMap.removeSource("my-source");
|
||||
|
||||
// Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
// Add initial source
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
// Remove
|
||||
Source mySource = mapboxMap.removeSource("my-source");
|
||||
assertNotNull(mySource);
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
// Remove
|
||||
Source mySource = mapboxMap.removeSource("my-source");
|
||||
assertNotNull(mySource);
|
||||
assertNull(mapboxMap.getLayer("my-source"));
|
||||
|
||||
// Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
// Add
|
||||
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Remove, preserving the reference
|
||||
mapboxMap.removeSource(source);
|
||||
// Remove, preserving the reference
|
||||
mapboxMap.removeSource(source);
|
||||
|
||||
// Re-add the reference...
|
||||
mapboxMap.addSource(source);
|
||||
// Re-add the reference...
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getSource(source.getId()));
|
||||
// Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getSource(source.getId()));
|
||||
|
||||
// Test adding a duplicate source
|
||||
try {
|
||||
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source2);
|
||||
fail("Should not have been allowed to add a source with a duplicate id");
|
||||
} catch (CannotAddSourceException cannotAddSourceException) {
|
||||
// OK
|
||||
}
|
||||
// Test adding a duplicate source
|
||||
try {
|
||||
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source2);
|
||||
fail("Should not have been allowed to add a source with a duplicate id");
|
||||
} catch (CannotAddSourceException cannotAddSourceException) {
|
||||
// OK
|
||||
}
|
||||
});
|
||||
|
||||
@@ -235,45 +230,36 @@ public class RuntimeStyleTests extends BaseActivityTest {
|
||||
@Test
|
||||
public void testVectorSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
|
||||
mapboxMap.addSource(source);
|
||||
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeoJsonSourceUrlGetter() throws MalformedURLException {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
GeoJsonSource source = new GeoJsonSource("my-source");
|
||||
mapboxMap.addSource(source);
|
||||
assertNull(source.getUrl());
|
||||
try {
|
||||
source.setUrl(new URL("http://mapbox.com/my-file.json"));
|
||||
} catch (MalformedURLException exception) {
|
||||
fail();
|
||||
}
|
||||
assertEquals("http://mapbox.com/my-file.json", source.getUrl());
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
GeoJsonSource source = new GeoJsonSource("my-source");
|
||||
mapboxMap.addSource(source);
|
||||
assertNull(source.getUrl());
|
||||
try {
|
||||
source.setUrl(new URL("http://mapbox.com/my-file.json"));
|
||||
} catch (MalformedURLException exception) {
|
||||
fail();
|
||||
}
|
||||
assertEquals("http://mapbox.com/my-file.json", source.getUrl());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.adapter.FeatureAdapter;
|
||||
@@ -62,19 +61,16 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClicked(RecyclerView recyclerView, int position, View view) {
|
||||
if (!sectionAdapter.isSectionHeaderPosition(position)) {
|
||||
int itemPosition = sectionAdapter.getConvertedPosition(position);
|
||||
Feature feature = features.get(itemPosition);
|
||||
if (feature.isRequiresLocationPermission()) {
|
||||
if (requestLocationPermission(itemPosition)) {
|
||||
return;
|
||||
}
|
||||
ItemClickSupport.addTo(recyclerView).setOnItemClickListener((recyclerView, position, view) -> {
|
||||
if (!sectionAdapter.isSectionHeaderPosition(position)) {
|
||||
int itemPosition = sectionAdapter.getConvertedPosition(position);
|
||||
Feature feature = features.get(itemPosition);
|
||||
if (feature.isRequiresLocationPermission()) {
|
||||
if (requestLocationPermission(itemPosition)) {
|
||||
return;
|
||||
}
|
||||
startFeature(feature);
|
||||
}
|
||||
startFeature(feature);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -188,15 +184,12 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
}
|
||||
|
||||
if (!features.isEmpty()) {
|
||||
Comparator<Feature> comparator = new Comparator<Feature>() {
|
||||
@Override
|
||||
public int compare(Feature lhs, Feature rhs) {
|
||||
int result = lhs.getCategory().compareToIgnoreCase(rhs.getCategory());
|
||||
if (result == 0) {
|
||||
result = lhs.getLabel().compareToIgnoreCase(rhs.getLabel());
|
||||
}
|
||||
return result;
|
||||
Comparator<Feature> comparator = (lhs, rhs) -> {
|
||||
int result = lhs.getCategory().compareToIgnoreCase(rhs.getCategory());
|
||||
if (result == 0) {
|
||||
result = lhs.getLabel().compareToIgnoreCase(rhs.getLabel());
|
||||
}
|
||||
return result;
|
||||
};
|
||||
Collections.sort(features, comparator);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.animation.TypeEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
@@ -24,7 +23,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
|
||||
import com.mapbox.services.api.utils.turf.TurfMeasurement;
|
||||
@@ -59,25 +57,18 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
AnimatedMarkerActivity.this.mapboxMap = mapboxMap;
|
||||
setupMap();
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
AnimatedMarkerActivity.this.mapboxMap = mapboxMap;
|
||||
setupMap();
|
||||
|
||||
animationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
addRandomCar();
|
||||
}
|
||||
addPassenger();
|
||||
addMainCar();
|
||||
}
|
||||
};
|
||||
mapView.post(animationRunnable);
|
||||
}
|
||||
animationRunnable = () -> {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
addRandomCar();
|
||||
}
|
||||
addPassenger();
|
||||
addMainCar();
|
||||
};
|
||||
mapView.post(animationRunnable);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,13 +107,10 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
|
||||
|
||||
if (carMarker == null) {
|
||||
carMarker = createCarMarker(randomLatLng, R.drawable.ic_taxi_top,
|
||||
new MarkerViewManager.OnMarkerViewAddedListener() {
|
||||
@Override
|
||||
public void onViewAdded(@NonNull MarkerView markerView) {
|
||||
// Make sure the car marker is selected so that it's always brought to the front (#5285)
|
||||
mapboxMap.selectMarker(carMarker);
|
||||
animateMoveToPassenger(carMarker);
|
||||
}
|
||||
markerView -> {
|
||||
// Make sure the car marker is selected so that it's always brought to the front (#5285)
|
||||
mapboxMap.selectMarker(carMarker);
|
||||
animateMoveToPassenger(carMarker);
|
||||
});
|
||||
markerViews.add(carMarker);
|
||||
} else {
|
||||
@@ -147,12 +135,7 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
|
||||
|
||||
protected void addRandomCar() {
|
||||
markerViews.add(createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top,
|
||||
new MarkerViewManager.OnMarkerViewAddedListener() {
|
||||
@Override
|
||||
public void onViewAdded(@NonNull MarkerView markerView) {
|
||||
randomlyMoveMarker(markerView);
|
||||
}
|
||||
}));
|
||||
markerView -> randomlyMoveMarker(markerView)));
|
||||
}
|
||||
|
||||
private void randomlyMoveMarker(final MarkerView marker) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -19,13 +18,11 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
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.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
|
||||
@@ -58,12 +55,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
BulkMarkerActivity.this.mapboxMap = mapboxMap;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> BulkMarkerActivity.this.mapboxMap = mapboxMap);
|
||||
|
||||
final View fab = findViewById(R.id.fab);
|
||||
if (fab != null) {
|
||||
@@ -232,29 +224,22 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
|
||||
|
||||
viewCountView = (TextView) findViewById(R.id.countView);
|
||||
|
||||
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(@MapView.MapChange int change) {
|
||||
if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
|
||||
if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
|
||||
viewCountView.setText(String.format(Locale.getDefault(), "ViewCache size %d",
|
||||
mapboxMap.getMarkerViewManager().getMarkerViewContainer().getChildCount()));
|
||||
}
|
||||
mapView.addOnMapChangedListener(change -> {
|
||||
if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
|
||||
if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
|
||||
viewCountView.setText(String.format(Locale.getDefault(), "ViewCache size %d",
|
||||
mapboxMap.getMarkerViewManager().getMarkerViewContainer().getChildCount()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
|
||||
new MapboxMap.OnMarkerViewClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClick(
|
||||
@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
|
||||
Toast.makeText(
|
||||
BulkMarkerActivity.this,
|
||||
"Hello " + marker.getId(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
(marker, view1, adapter) -> {
|
||||
Toast.makeText(
|
||||
BulkMarkerActivity.this,
|
||||
"Hello " + marker.getId(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
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.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
|
||||
|
||||
@@ -37,29 +34,23 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setTag(false);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
DynamicMarkerChangeActivity.this.mapboxMap = mapboxMap;
|
||||
// Create marker
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(LAT_LNG_CHELSEA)
|
||||
.icon(IconUtils.drawableToIcon(DynamicMarkerChangeActivity.this, R.drawable.ic_stars,
|
||||
ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme())))
|
||||
.title(getString(R.string.dynamic_marker_chelsea_title))
|
||||
.snippet(getString(R.string.dynamic_marker_chelsea_snippet));
|
||||
marker = mapboxMap.addMarker(markerOptions);
|
||||
}
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
DynamicMarkerChangeActivity.this.mapboxMap = mapboxMap;
|
||||
// Create marker
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(LAT_LNG_CHELSEA)
|
||||
.icon(IconUtils.drawableToIcon(DynamicMarkerChangeActivity.this, R.drawable.ic_stars,
|
||||
ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme())))
|
||||
.title(getString(R.string.dynamic_marker_chelsea_title))
|
||||
.snippet(getString(R.string.dynamic_marker_chelsea_snippet));
|
||||
marker = mapboxMap.addMarker(markerOptions);
|
||||
});
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
updateMarker();
|
||||
}
|
||||
fab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
updateMarker();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
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.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerViewOptions;
|
||||
@@ -81,127 +80,117 @@ public class MarkerViewActivity extends AppCompatActivity {
|
||||
final TextView viewCountView = (TextView) findViewById(R.id.countView);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
MarkerViewActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
MarkerViewActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
|
||||
final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
|
||||
|
||||
Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this)
|
||||
.fromResource(R.drawable.ic_us);
|
||||
Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this)
|
||||
.fromResource(R.drawable.ic_us);
|
||||
|
||||
// add default ViewMarker markers
|
||||
for (int i = 0; i < LAT_LNGS.length; i++) {
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(LAT_LNGS[i])
|
||||
.title(String.valueOf(i))
|
||||
.alpha(0.5f)
|
||||
.icon(usFlag)
|
||||
);
|
||||
}
|
||||
|
||||
// add custom ViewMarker
|
||||
CountryMarkerViewOptions options = new CountryMarkerViewOptions();
|
||||
options.flagRes(R.drawable.icon_burned);
|
||||
options.abbrevName("Mapbox");
|
||||
options.title("Hello");
|
||||
options.position(new LatLng(38.899774, -77.023237));
|
||||
options.flat(true);
|
||||
MarkerView markerView = mapboxMap.addMarker(options);
|
||||
|
||||
// Use object animator to rotate MarkerView
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(markerView, "rotation", new FloatEvaluator(), -90, 90);
|
||||
markerAnimator.setDuration(5000);
|
||||
markerAnimator.start();
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
|
||||
.title("United States")
|
||||
.position(new LatLng(38.902580, -77.050102))
|
||||
// add default ViewMarker markers
|
||||
for (int i = 0; i < LAT_LNGS.length; i++) {
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(LAT_LNGS[i])
|
||||
.title(String.valueOf(i))
|
||||
.alpha(0.5f)
|
||||
.icon(usFlag)
|
||||
);
|
||||
}
|
||||
|
||||
rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("A")
|
||||
.rotation(rotation = 270)
|
||||
.position(new LatLng(38.889876, -77.008849))
|
||||
);
|
||||
loopMarkerRotate();
|
||||
// add custom ViewMarker
|
||||
CountryMarkerViewOptions options = new CountryMarkerViewOptions();
|
||||
options.flagRes(R.drawable.icon_burned);
|
||||
options.abbrevName("Mapbox");
|
||||
options.title("Hello");
|
||||
options.position(new LatLng(38.899774, -77.023237));
|
||||
options.flat(true);
|
||||
MarkerView markerView = mapboxMap.addMarker(options);
|
||||
|
||||
// Use object animator to rotate MarkerView
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(markerView, "rotation", new FloatEvaluator(), -90, 90);
|
||||
markerAnimator.setDuration(5000);
|
||||
markerAnimator.start();
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
|
||||
.title("United States")
|
||||
.position(new LatLng(38.902580, -77.050102))
|
||||
);
|
||||
|
||||
rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("A")
|
||||
.rotation(rotation = 270)
|
||||
.position(new LatLng(38.889876, -77.008849))
|
||||
);
|
||||
loopMarkerRotate();
|
||||
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("B")
|
||||
.position(new LatLng(38.907327, -77.041293))
|
||||
);
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("B")
|
||||
.position(new LatLng(38.907327, -77.041293))
|
||||
);
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("C")
|
||||
.position(new LatLng(38.897642, -77.041980))
|
||||
);
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("C")
|
||||
.position(new LatLng(38.897642, -77.041980))
|
||||
);
|
||||
|
||||
// if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation
|
||||
// set adapters for child classes of ViewMarker
|
||||
markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
// if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation
|
||||
// set adapters for child classes of ViewMarker
|
||||
markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
|
||||
final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer();
|
||||
final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer();
|
||||
|
||||
// add a change listener to validate the size of amount of child views
|
||||
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(@MapView.MapChange int change) {
|
||||
if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
|
||||
if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) {
|
||||
viewCountView.setText(String.format(
|
||||
Locale.getDefault(),
|
||||
getString(R.string.viewcache_size),
|
||||
markerViewContainer.getChildCount())
|
||||
);
|
||||
}
|
||||
}
|
||||
// add a change listener to validate the size of amount of child views
|
||||
mapView.addOnMapChangedListener(change -> {
|
||||
if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
|
||||
if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) {
|
||||
viewCountView.setText(String.format(
|
||||
Locale.getDefault(),
|
||||
getString(R.string.viewcache_size),
|
||||
markerViewContainer.getChildCount())
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add a OnMarkerView click listener
|
||||
MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
|
||||
(marker, view, adapter) -> {
|
||||
Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
});
|
||||
|
||||
// add a OnMarkerView click listener
|
||||
MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
|
||||
new MapboxMap.OnMarkerViewClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view,
|
||||
@NonNull MapboxMap.MarkerViewAdapter adapter) {
|
||||
Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_0_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android))
|
||||
);
|
||||
|
||||
movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_0_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android))
|
||||
);
|
||||
movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_1_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android_2))
|
||||
);
|
||||
|
||||
movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_1_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android_2))
|
||||
);
|
||||
// allow more open infowindows at the same time
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
|
||||
// allow more open infowindows at the same time
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
// add offscreen markers
|
||||
Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.892846, -76.909399))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the right of the Map."));
|
||||
|
||||
// add offscreen markers
|
||||
Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.892846, -76.909399))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the right of the Map."));
|
||||
Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.791645, -77.039006))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the bottom of the Map"));
|
||||
|
||||
Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.791645, -77.039006))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the bottom of the Map"));
|
||||
|
||||
// open infowindow offscreen markers
|
||||
mapboxMap.selectMarker(markerRightOffScreen);
|
||||
mapboxMap.selectMarker(markerRightBottomOffScreen);
|
||||
}
|
||||
// open infowindow offscreen markers
|
||||
mapboxMap.selectMarker(markerRightOffScreen);
|
||||
mapboxMap.selectMarker(markerRightBottomOffScreen);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -78,16 +77,11 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
|
||||
map.setOnPolygonClickListener(new MapboxMap.OnPolygonClickListener() {
|
||||
@Override
|
||||
public void onPolygonClick(@NonNull Polygon polygon) {
|
||||
Toast.makeText(
|
||||
PolygonActivity.this,
|
||||
"You clicked on polygon with id = " + polygon.getId(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
}
|
||||
});
|
||||
map.setOnPolygonClickListener(polygon -> Toast.makeText(
|
||||
PolygonActivity.this,
|
||||
"You clicked on polygon with id = " + polygon.getId(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show());
|
||||
|
||||
polygon = mapboxMap.addPolygon(new PolygonOptions()
|
||||
.addAll(STAR_SHAPE_POINTS)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -14,7 +13,6 @@ import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
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.testapp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -65,46 +63,35 @@ public class PolylineActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
PolylineActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
PolylineActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
mapboxMap.setOnPolylineClickListener(new MapboxMap.OnPolylineClickListener() {
|
||||
@Override
|
||||
public void onPolylineClick(@NonNull Polyline polyline) {
|
||||
Toast.makeText(
|
||||
PolylineActivity.this,
|
||||
"You clicked on polygon with id = " + polyline.getId(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnPolylineClickListener(polyline -> Toast.makeText(
|
||||
PolylineActivity.this,
|
||||
"You clicked on polygon with id = " + polyline.getId(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show());
|
||||
|
||||
polylines = mapboxMap.addPolylines(polylineOptions);
|
||||
}
|
||||
polylines = mapboxMap.addPolylines(polylineOptions);
|
||||
});
|
||||
|
||||
View fab = findViewById(R.id.fab);
|
||||
if (fab != null) {
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
if (polylines != null && polylines.size() > 0) {
|
||||
if (polylines.size() == 1) {
|
||||
// test for removing annotation
|
||||
mapboxMap.removeAnnotation(polylines.get(0));
|
||||
} else {
|
||||
// test for removing annotations
|
||||
mapboxMap.removeAnnotations(polylines);
|
||||
}
|
||||
fab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
if (polylines != null && polylines.size() > 0) {
|
||||
if (polylines.size() == 1) {
|
||||
// test for removing annotation
|
||||
mapboxMap.removeAnnotation(polylines.get(0));
|
||||
} else {
|
||||
// test for removing annotations
|
||||
mapboxMap.removeAnnotations(polylines);
|
||||
}
|
||||
polylineOptions.clear();
|
||||
polylineOptions.addAll(getRandomLine());
|
||||
polylines = mapboxMap.addPolylines(polylineOptions);
|
||||
|
||||
}
|
||||
polylineOptions.clear();
|
||||
polylineOptions.addAll(getRandomLine());
|
||||
polylines = mapboxMap.addPolylines(polylineOptions);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
@@ -12,7 +11,6 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
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.testapp.R;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
@@ -41,30 +39,17 @@ public class PressForMarkerActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
resetMap();
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
resetMap();
|
||||
|
||||
mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {
|
||||
@Override
|
||||
public void onMapLongClick(@NonNull LatLng point) {
|
||||
addMarker(point);
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnMapLongClickListener(point -> addMarker(point));
|
||||
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
addMarker(point);
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnMapClickListener(point -> addMarker(point));
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
}
|
||||
if (savedInstanceState != null) {
|
||||
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
|
||||
mapboxMap.addMarkers(markerList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,102 +47,88 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On
|
||||
mapboxMap = map;
|
||||
mapboxMap.getUiSettings().setAttributionEnabled(false);
|
||||
mapboxMap.getUiSettings().setLogoEnabled(false);
|
||||
mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition position) {
|
||||
Timber.w(position.toString());
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnCameraChangeListener(position -> Timber.w(position.toString()));
|
||||
|
||||
// handle move button clicks
|
||||
View moveButton = findViewById(R.id.cameraMoveButton);
|
||||
if (moveButton != null) {
|
||||
moveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.zoom(14)
|
||||
.tilt(30)
|
||||
.tilt(0)
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
moveButton.setOnClickListener(view -> {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.zoom(14)
|
||||
.tilt(30)
|
||||
.tilt(0)
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
});
|
||||
}
|
||||
|
||||
// handle ease button clicks
|
||||
View easeButton = findViewById(R.id.cameraEaseButton);
|
||||
if (easeButton != null) {
|
||||
easeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.zoom(15)
|
||||
.bearing(180)
|
||||
.tilt(30)
|
||||
.build();
|
||||
easeButton.setOnClickListener(view -> {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.zoom(15)
|
||||
.bearing(180)
|
||||
.tilt(30)
|
||||
.build();
|
||||
|
||||
MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Timber.i("Duration onCancel Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Ease onCancel Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Timber.i("Duration onCancel Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Ease onCancel Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Timber.i("Duration onFinish Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Ease onFinish Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Timber.i("Duration onFinish Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Ease onFinish Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
|
||||
}
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
|
||||
});
|
||||
}
|
||||
|
||||
// handle animate button clicks
|
||||
View animateButton = findViewById(R.id.cameraAnimateButton);
|
||||
if (animateButton != null) {
|
||||
animateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.bearing(270)
|
||||
.tilt(20)
|
||||
.build();
|
||||
animateButton.setOnClickListener(view -> {
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(getNextLatLng())
|
||||
.bearing(270)
|
||||
.tilt(20)
|
||||
.build();
|
||||
|
||||
MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Timber.i("Duration onCancel Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Duration onCancel Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Timber.i("Duration onCancel Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Duration onCancel Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Timber.i("Duration onFinish Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Duration onFinish Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Timber.i("Duration onFinish Callback called.");
|
||||
Toast.makeText(
|
||||
CameraAnimationTypeActivity.this,
|
||||
"Duration onFinish Callback called.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
|
||||
}
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,44 +35,30 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
|
||||
private final LongSparseArray<AnimatorBuilder> animators = new LongSparseArray<AnimatorBuilder>() {
|
||||
{
|
||||
put(R.id.menu_action_accelerate_decelerate_interpolator, new AnimatorBuilder() {
|
||||
@Override
|
||||
public Animator build() {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
createLatLngAnimator(START_LAT_LNG, new LatLng(37.826715, -122.422795)),
|
||||
obtainExampleInterpolator(new FastOutSlowInInterpolator(), 2500)
|
||||
);
|
||||
return animatorSet;
|
||||
}
|
||||
put(R.id.menu_action_accelerate_decelerate_interpolator, () -> {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
createLatLngAnimator(START_LAT_LNG, new LatLng(37.826715, -122.422795)),
|
||||
obtainExampleInterpolator(new FastOutSlowInInterpolator(), 2500)
|
||||
);
|
||||
return animatorSet;
|
||||
});
|
||||
|
||||
put(R.id.menu_action_bounce_interpolator, new AnimatorBuilder() {
|
||||
@Override
|
||||
public Animator build() {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
createLatLngAnimator(START_LAT_LNG, new LatLng(37.787947, -122.407432)),
|
||||
obtainExampleInterpolator(new BounceInterpolator(), 3750)
|
||||
);
|
||||
return animatorSet;
|
||||
}
|
||||
put(R.id.menu_action_bounce_interpolator, () -> {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
createLatLngAnimator(START_LAT_LNG, new LatLng(37.787947, -122.407432)),
|
||||
obtainExampleInterpolator(new BounceInterpolator(), 3750)
|
||||
);
|
||||
return animatorSet;
|
||||
});
|
||||
|
||||
put(R.id.menu_action_anticipate_overshoot_interpolator, new AnimatorBuilder() {
|
||||
@Override
|
||||
public Animator build() {
|
||||
return obtainExampleInterpolator(new AnticipateOvershootInterpolator(), 2500);
|
||||
}
|
||||
});
|
||||
put(R.id.menu_action_anticipate_overshoot_interpolator, () ->
|
||||
obtainExampleInterpolator(new AnticipateOvershootInterpolator(), 2500)
|
||||
);
|
||||
|
||||
put(R.id.menu_action_path_interpolator, new AnimatorBuilder() {
|
||||
@Override
|
||||
public Animator build() {
|
||||
return obtainExampleInterpolator(
|
||||
PathInterpolatorCompat.create(.22f, .68f, 0, 1.71f), 2500);
|
||||
}
|
||||
});
|
||||
put(R.id.menu_action_path_interpolator, () -> obtainExampleInterpolator(
|
||||
PathInterpolatorCompat.create(.22f, .68f, 0, 1.71f), 2500));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -98,20 +84,17 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
}
|
||||
|
||||
private void initFab() {
|
||||
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
view.setVisibility(View.GONE);
|
||||
findViewById(R.id.fab).setOnClickListener(view -> {
|
||||
view.setVisibility(View.GONE);
|
||||
|
||||
CameraPosition animatedPosition = new CameraPosition.Builder()
|
||||
.target(new LatLng(37.789992, -122.402214))
|
||||
.tilt(60)
|
||||
.zoom(14.5f)
|
||||
.bearing(135)
|
||||
.build();
|
||||
CameraPosition animatedPosition = new CameraPosition.Builder()
|
||||
.target(new LatLng(37.789992, -122.402214))
|
||||
.tilt(60)
|
||||
.zoom(14.5f)
|
||||
.bearing(135)
|
||||
.build();
|
||||
|
||||
createExampleAnimator(mapboxMap.getCameraPosition(), animatedPosition).start();
|
||||
}
|
||||
createExampleAnimator(mapboxMap.getCameraPosition(), animatedPosition).start();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,12 +115,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator latLngAnimator = ValueAnimator.ofObject(new LatLngEvaluator(), currentPosition, targetPosition);
|
||||
latLngAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
latLngAnimator.setInterpolator(new FastOutSlowInInterpolator());
|
||||
latLngAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mapboxMap.setLatLng((LatLng) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
latLngAnimator.addUpdateListener(animation -> mapboxMap.setLatLng((LatLng) animation.getAnimatedValue()));
|
||||
return latLngAnimator;
|
||||
}
|
||||
|
||||
@@ -146,12 +124,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
zoomAnimator.setDuration((long) (2200 * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setStartDelay((long) (600 * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setInterpolator(new AnticipateOvershootInterpolator());
|
||||
zoomAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mapboxMap.setZoom((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.setZoom((Float) animation.getAnimatedValue()));
|
||||
return zoomAnimator;
|
||||
}
|
||||
|
||||
@@ -160,12 +133,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
bearingAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
bearingAnimator.setStartDelay((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
bearingAnimator.setInterpolator(new FastOutLinearInInterpolator());
|
||||
bearingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mapboxMap.setBearing((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
bearingAnimator.addUpdateListener(animation -> mapboxMap.setBearing((Float) animation.getAnimatedValue()));
|
||||
return bearingAnimator;
|
||||
}
|
||||
|
||||
@@ -173,12 +141,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator tiltAnimator = ValueAnimator.ofFloat((float) currentTilt, (float) targetTilt);
|
||||
tiltAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
tiltAnimator.setStartDelay((long) (1500 * ANIMATION_DELAY_FACTOR));
|
||||
tiltAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mapboxMap.setTilt((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
tiltAnimator.addUpdateListener(animation -> mapboxMap.setTilt((Float) animation.getAnimatedValue()));
|
||||
return tiltAnimator;
|
||||
}
|
||||
|
||||
@@ -229,12 +192,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator zoomAnimator = ValueAnimator.ofFloat(11.0f, 16.0f);
|
||||
zoomAnimator.setDuration((long) (duration * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setInterpolator(interpolator);
|
||||
zoomAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mapboxMap.setZoom((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.setZoom((Float) animation.getAnimatedValue()));
|
||||
return zoomAnimator;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,13 +162,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe
|
||||
}
|
||||
};
|
||||
|
||||
private MapboxMap.OnCameraMoveCanceledListener moveCanceledListener = new MapboxMap.OnCameraMoveCanceledListener() {
|
||||
@Override
|
||||
public void onCameraMoveCanceled() {
|
||||
Timber.e("OnCameraMoveCanceled");
|
||||
|
||||
}
|
||||
};
|
||||
private MapboxMap.OnCameraMoveCanceledListener moveCanceledListener = () -> Timber.e("OnCameraMoveCanceled");
|
||||
|
||||
private MapboxMap.OnCameraMoveStartedListener moveStartedListener = new MapboxMap.OnCameraMoveStartedListener() {
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.view.LockableBottomSheetBehavior;
|
||||
|
||||
@@ -55,12 +54,9 @@ public class LatLngBoundsActivity extends AppCompatActivity implements View.OnCl
|
||||
setContentView(R.layout.activity_latlngbounds);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
initMap();
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
initMap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.camera;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -12,7 +11,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
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.R;
|
||||
|
||||
@@ -35,14 +33,11 @@ public class ManualZoomActivity extends AppCompatActivity {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setStyleUrl(Style.SATELLITE);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
ManualZoomActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
ManualZoomActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(false);
|
||||
}
|
||||
UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.camera;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
@@ -37,17 +35,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
|
||||
mapboxMap = map;
|
||||
mapboxMap.setMinZoomPreference(3);
|
||||
mapboxMap.setMaxZoomPreference(5);
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
map.setStyle(Style.OUTDOORS, new MapboxMap.OnStyleLoadedListener() {
|
||||
@Override
|
||||
public void onStyleLoaded(String style) {
|
||||
Timber.d("Style Loaded %s", style);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnMapClickListener(point -> map.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -69,15 +68,10 @@ public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCal
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setColorFilter(ContextCompat.getColor(ScrollByActivity.this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
|
||||
seekBarX.getProgress() * MULTIPLIER_PER_PIXEL,
|
||||
seekBarY.getProgress() * MULTIPLIER_PER_PIXEL)
|
||||
);
|
||||
}
|
||||
});
|
||||
fab.setOnClickListener(view -> mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
|
||||
seekBarX.getProgress() * MULTIPLIER_PER_PIXEL,
|
||||
seekBarY.getProgress() * MULTIPLIER_PER_PIXEL)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,13 +6,11 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.CustomLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer;
|
||||
@@ -38,23 +36,17 @@ public class CustomLayerActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10));
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
swapCustomLayer();
|
||||
}
|
||||
fab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
swapCustomLayer();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.widget.Toast;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.services.commons.geojson.Feature;
|
||||
|
||||
@@ -36,32 +35,25 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap mapboxMap) {
|
||||
QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
|
||||
selectionBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box);
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
|
||||
selectionBox.setOnClickListener(view -> {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box);
|
||||
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
QueryRenderedFeaturesBoxCountActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
QueryRenderedFeaturesBoxCountActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
// Debug output
|
||||
debugOutput(features);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Debug output
|
||||
debugOutput(features);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -41,41 +40,34 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap mapboxMap) {
|
||||
QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
// Add layer / source
|
||||
final GeoJsonSource source = new GeoJsonSource("highlighted-shapes-source");
|
||||
mapboxMap.addSource(source);
|
||||
mapboxMap.addLayer(
|
||||
new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source")
|
||||
.withProperties(fillColor(Color.RED))
|
||||
);
|
||||
// Add layer / source
|
||||
final GeoJsonSource source = new GeoJsonSource("highlighted-shapes-source");
|
||||
mapboxMap.addSource(source);
|
||||
mapboxMap.addLayer(
|
||||
new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source")
|
||||
.withProperties(fillColor(Color.RED))
|
||||
);
|
||||
|
||||
selectionBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s for buildings", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, Filter.lt("height", 10), "building");
|
||||
selectionBox.setOnClickListener(view -> {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s for buildings", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, Filter.lt("height", 10), "building");
|
||||
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
QueryRenderedFeaturesBoxHighlightActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
QueryRenderedFeaturesBoxHighlightActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
// Update source data
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(features));
|
||||
}
|
||||
});
|
||||
}
|
||||
// Update source data
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(features));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -43,49 +42,42 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap mapboxMap) {
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
// Add a symbol layer (also works with annotations)
|
||||
try {
|
||||
mapboxMap.addSource(new GeoJsonSource("symbols-source", ResourceUtils.readRawResource(
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this, R.raw.test_points_utrecht)));
|
||||
} catch (IOException ioException) {
|
||||
Timber.e(ioException, "Could not load geojson");
|
||||
return;
|
||||
}
|
||||
mapboxMap.addImage(
|
||||
"test-icon",
|
||||
BitmapFactory.decodeResource(getResources(),
|
||||
R.drawable.mapbox_marker_icon_default)
|
||||
);
|
||||
mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
|
||||
|
||||
selectionBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, "symbols-layer");
|
||||
|
||||
// Show count
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
}
|
||||
toast = Toast.makeText(
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
});
|
||||
// Add a symbol layer (also works with annotations)
|
||||
try {
|
||||
mapboxMap.addSource(new GeoJsonSource("symbols-source", ResourceUtils.readRawResource(
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this, R.raw.test_points_utrecht)));
|
||||
} catch (IOException ioException) {
|
||||
Timber.e(ioException, "Could not load geojson");
|
||||
return;
|
||||
}
|
||||
mapboxMap.addImage(
|
||||
"test-icon",
|
||||
BitmapFactory.decodeResource(getResources(),
|
||||
R.drawable.mapbox_marker_icon_default)
|
||||
);
|
||||
mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
|
||||
|
||||
selectionBox.setOnClickListener(view -> {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, "symbols-layer");
|
||||
|
||||
// Show count
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
}
|
||||
toast = Toast.makeText(
|
||||
QueryRenderedFeaturesBoxSymbolCountActivity.this,
|
||||
String.format("%s features in box", features.size()),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,8 @@ import android.widget.TextView;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
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.testapp.R;
|
||||
import com.mapbox.services.commons.geojson.Feature;
|
||||
|
||||
@@ -45,40 +43,34 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap mapboxMap) {
|
||||
QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
// Add custom window adapter
|
||||
addCustomInfoWindowAdapter(mapboxMap);
|
||||
// Add custom window adapter
|
||||
addCustomInfoWindowAdapter(mapboxMap);
|
||||
|
||||
// Add a click listener
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
// Query
|
||||
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
|
||||
Timber.i(
|
||||
"Requesting features for %sx%s (%sx%s adjusted for density)",
|
||||
pixel.x, pixel.y, pixel.x / density, pixel.y / density
|
||||
);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
|
||||
// Add a click listener
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// Query
|
||||
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
|
||||
Timber.i(
|
||||
"Requesting features for %sx%s (%sx%s adjusted for density)",
|
||||
pixel.x, pixel.y, pixel.x / density, pixel.y / density
|
||||
);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
|
||||
|
||||
// Debug output
|
||||
debugOutput(features);
|
||||
// Debug output
|
||||
debugOutput(features);
|
||||
|
||||
// Remove any previous markers
|
||||
if (marker != null) {
|
||||
mapboxMap.removeMarker(marker);
|
||||
}
|
||||
// Remove any previous markers
|
||||
if (marker != null) {
|
||||
mapboxMap.removeMarker(marker);
|
||||
}
|
||||
|
||||
// Add a marker on the clicked point
|
||||
marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Add a marker on the clicked point
|
||||
marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
|
||||
mapboxMap.selectMarker(marker);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.feature;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
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.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -38,32 +35,26 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(final MapboxMap mapboxMap) {
|
||||
QuerySourceFeaturesActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
QuerySourceFeaturesActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
JsonObject properties = new JsonObject();
|
||||
properties.addProperty("key1", "value1");
|
||||
final GeoJsonSource source = new GeoJsonSource("test-source",
|
||||
FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {0, 0}), properties)
|
||||
}));
|
||||
mapboxMap.addSource(source);
|
||||
JsonObject properties = new JsonObject();
|
||||
properties.addProperty("key1", "value1");
|
||||
final GeoJsonSource source = new GeoJsonSource("test-source",
|
||||
FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {0, 0}), properties)
|
||||
}));
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(Filter.neq("key1", "value1")));
|
||||
mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(Filter.neq("key1", "value1")));
|
||||
|
||||
// Add a click listener
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
// Query
|
||||
List<Feature> features = source.querySourceFeatures(Filter.eq("key1", "value1"));
|
||||
Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features",
|
||||
features.size()), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Add a click listener
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// Query
|
||||
List<Feature> features = source.querySourceFeatures(Filter.eq("key1", "value1"));
|
||||
Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features",
|
||||
features.size()), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.fragment;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@ package com.mapbox.mapboxsdk.testapp.activity.imagegenerator;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.print.PrintHelper;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -27,21 +25,13 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
PrintActivity.this.mapboxMap = mapboxMap;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> PrintActivity.this.mapboxMap = mapboxMap);
|
||||
|
||||
final View fab = findViewById(R.id.fab);
|
||||
if (fab != null) {
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap.snapshot(PrintActivity.this);
|
||||
}
|
||||
fab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap.snapshot(PrintActivity.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.imagegenerator;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@@ -49,18 +48,15 @@ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCal
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final long startTime = System.nanoTime();
|
||||
mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
|
||||
@Override
|
||||
public void onSnapshotReady(Bitmap snapshot) {
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (long) ((endTime - startTime) / 1e6);
|
||||
ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
|
||||
snapshotView.setImageBitmap(snapshot);
|
||||
Toast.makeText(
|
||||
SnapshotActivity.this,
|
||||
String.format(Locale.getDefault(), "Snapshot taken in %d ms", duration),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
mapboxMap.snapshot(snapshot -> {
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (long) ((endTime - startTime) / 1e6);
|
||||
ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
|
||||
snapshotView.setImageBitmap(snapshot);
|
||||
Toast.makeText(
|
||||
SnapshotActivity.this,
|
||||
String.format(Locale.getDefault(), "Snapshot taken in %d ms", duration),
|
||||
Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,11 @@ package com.mapbox.mapboxsdk.testapp.activity.infowindow;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.InfoWindow;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
@@ -57,28 +54,22 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
|
||||
mapboxMap.selectMarker(marker);
|
||||
|
||||
// On map click, change the info window contents
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
// Distance from click to marker
|
||||
double distanceKm = marker.getPosition().distanceTo(point) / 1000;
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// Distance from click to marker
|
||||
double distanceKm = marker.getPosition().distanceTo(point) / 1000;
|
||||
|
||||
// Get the info window
|
||||
final InfoWindow infoWindow = marker.getInfoWindow();
|
||||
// Get the info window
|
||||
final InfoWindow infoWindow = marker.getInfoWindow();
|
||||
|
||||
// Get the view from the info window
|
||||
if (infoWindow != null && infoWindow.getView() != null) {
|
||||
// Set the new text on the text view in the info window
|
||||
TextView textView = (TextView) infoWindow.getView();
|
||||
textView.setText(String.format(Locale.getDefault(), "%.2fkm", distanceKm));
|
||||
textView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Update the info window position (as the text length changes)
|
||||
infoWindow.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Get the view from the info window
|
||||
if (infoWindow != null && infoWindow.getView() != null) {
|
||||
// Set the new text on the text view in the info window
|
||||
TextView textView = (TextView) infoWindow.getView();
|
||||
textView.setText(String.format(Locale.getDefault(), "%.2fkm", distanceKm));
|
||||
textView.post(() -> {
|
||||
// Update the info window position (as the text length changes)
|
||||
infoWindow.update();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -97,17 +88,13 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
|
||||
|
||||
private void addCustomInfoWindowAdapter(final MapboxMap mapboxMap) {
|
||||
final int padding = (int) getResources().getDimension(R.dimen.attr_margin);
|
||||
mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
|
||||
|
||||
@Override
|
||||
public View getInfoWindow(@NonNull Marker marker) {
|
||||
TextView textView = new TextView(DynamicInfoWindowAdapterActivity.this);
|
||||
textView.setText(marker.getTitle());
|
||||
textView.setBackgroundColor(Color.WHITE);
|
||||
textView.setText(R.string.action_calculate_distance);
|
||||
textView.setPadding(padding, padding, padding, padding);
|
||||
return textView;
|
||||
}
|
||||
mapboxMap.setInfoWindowAdapter(marker -> {
|
||||
TextView textView = new TextView(DynamicInfoWindowAdapterActivity.this);
|
||||
textView.setText(marker.getTitle());
|
||||
textView.setBackgroundColor(Color.WHITE);
|
||||
textView.setText(R.string.action_calculate_distance);
|
||||
textView.setPadding(padding, padding, padding, padding);
|
||||
return textView;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
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.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarker;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions;
|
||||
@@ -33,13 +32,10 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
addMarkers();
|
||||
addCustomInfoWindowAdapter();
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
addMarkers();
|
||||
addCustomInfoWindowAdapter();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -47,19 +47,9 @@ public class BottomSheetActivity extends AppCompatActivity {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
findViewById(R.id.fabFragment).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addMapFragment();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.fabFragment).setOnClickListener(v -> addMapFragment());
|
||||
|
||||
findViewById(R.id.fabBottomSheet).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleBottomSheetMapFragment();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.fabBottomSheet).setOnClickListener(v -> toggleBottomSheetMapFragment());
|
||||
|
||||
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
|
||||
bottomSheetBehavior.setPeekHeight((int) (64 * getResources().getDisplayMetrics().density));
|
||||
|
||||
@@ -11,12 +11,10 @@ import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -82,13 +80,10 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(int change) {
|
||||
if (change == MapView.DID_FINISH_LOADING_STYLE && mapboxMap != null) {
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
|
||||
setupNavigationView(mapboxMap.getLayers());
|
||||
}
|
||||
mapView.addOnMapChangedListener(change -> {
|
||||
if (change == MapView.DID_FINISH_LOADING_STYLE && mapboxMap != null) {
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
|
||||
setupNavigationView(mapboxMap.getLayers());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -110,25 +105,19 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
|
||||
|
||||
private void setFpsView() {
|
||||
final TextView fpsView = (TextView) findViewById(R.id.fpsView);
|
||||
mapboxMap.setOnFpsChangedListener(new MapboxMap.OnFpsChangedListener() {
|
||||
@Override
|
||||
public void onFpsChanged(double fps) {
|
||||
fpsView.setText(String.format(Locale.US,"FPS: %4.2f", fps));
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnFpsChangedListener(fps ->
|
||||
fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps))
|
||||
);
|
||||
}
|
||||
|
||||
private void setupNavigationView(List<Layer> layerList) {
|
||||
final LayerListAdapter adapter = new LayerListAdapter(this, layerList);
|
||||
ListView listView = (ListView) findViewById(R.id.listView);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Layer clickedLayer = adapter.getItem(position);
|
||||
toggleLayerVisibility(clickedLayer);
|
||||
closeNavigationView();
|
||||
}
|
||||
listView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Layer clickedLayer = adapter.getItem(position);
|
||||
toggleLayerVisibility(clickedLayer);
|
||||
closeNavigationView();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,44 +137,30 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
|
||||
|
||||
private void setupZoomView() {
|
||||
final TextView textView = (TextView) findViewById(R.id.textZoom);
|
||||
mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition position) {
|
||||
textView.setText(String.format(getString(R.string.debug_zoom), position.zoom));
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnCameraChangeListener(position ->
|
||||
textView.setText(String.format(getString(R.string.debug_zoom), position.zoom))
|
||||
);
|
||||
}
|
||||
|
||||
private void setupDebugChangeView() {
|
||||
FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
|
||||
fabDebug.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
|
||||
mapboxMap.cycleDebugOptions();
|
||||
}
|
||||
fabDebug.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
|
||||
mapboxMap.cycleDebugOptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupStyleChangeView() {
|
||||
FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
|
||||
fabStyles.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
currentStyleIndex++;
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], new MapboxMap.OnStyleLoadedListener() {
|
||||
@Override
|
||||
public void onStyleLoaded(String style) {
|
||||
Timber.d("Style loaded %s", style);
|
||||
}
|
||||
});
|
||||
fabStyles.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
currentStyleIndex++;
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -14,10 +13,8 @@ import android.view.ViewGroup;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
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.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -90,47 +87,38 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
// MapView large
|
||||
mapView = (MapView) view.findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
if (activity != null) {
|
||||
activity.setMapboxMap(mapboxMap);
|
||||
}
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
if (activity != null) {
|
||||
activity.setMapboxMap(mapboxMap);
|
||||
}
|
||||
});
|
||||
|
||||
// MapView mini
|
||||
mapViewMini = (MapView) view.findViewById(R.id.mini_map);
|
||||
mapViewMini.onCreate(savedInstanceState);
|
||||
mapViewMini.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
mapboxMap.setStyleUrl(Style.LIGHT);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4));
|
||||
mapViewMini.getMapAsync(mapboxMap -> {
|
||||
mapboxMap.setStyleUrl(Style.LIGHT);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4));
|
||||
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(false);
|
||||
uiSettings.setCompassEnabled(false);
|
||||
uiSettings.setAttributionEnabled(false);
|
||||
uiSettings.setLogoEnabled(false);
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(false);
|
||||
uiSettings.setCompassEnabled(false);
|
||||
uiSettings.setAttributionEnabled(false);
|
||||
uiSettings.setLogoEnabled(false);
|
||||
|
||||
try {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
} catch (SecurityException securityException) {
|
||||
// permission is handled in MainActivity
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
// test if we can open 2 activities after each other
|
||||
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
|
||||
}
|
||||
});
|
||||
try {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
} catch (SecurityException securityException) {
|
||||
// permission is handled in MainActivity
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// test if we can open 2 activities after each other
|
||||
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.testapp.R;
|
||||
|
||||
import timber.log.Timber;
|
||||
@@ -28,21 +27,13 @@ public class MapChangeActivity extends AppCompatActivity {
|
||||
|
||||
final LongSparseArray<String> mapChangeMap = buildMapChangeStringValueSparseArray();
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(int change) {
|
||||
Timber.e("OnMapChange: %s, %s", change, mapChangeMap.get(change));
|
||||
}
|
||||
});
|
||||
mapView.addOnMapChangedListener(change -> Timber.e("OnMapChange: %s, %s", change, mapChangeMap.get(change)));
|
||||
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(55.754020, 37.620948), 12), 9000);
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(55.754020, 37.620948), 12), 9000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,10 @@ public class MapInDialogActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_map_in_dialog);
|
||||
|
||||
Button button = (Button) findViewById(R.id.button_open_dialog);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
MapDialogFragment editNameDialogFragment = MapDialogFragment.newInstance("Map Dialog");
|
||||
editNameDialogFragment.show(fm, "fragment_dialog_map");
|
||||
}
|
||||
button.setOnClickListener(view -> {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
MapDialogFragment editNameDialogFragment = MapDialogFragment.newInstance("Map Dialog");
|
||||
editNameDialogFragment.show(fm, "fragment_dialog_map");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -13,7 +12,6 @@ import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
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.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
@@ -37,19 +35,16 @@ public class MapPaddingActivity extends AppCompatActivity {
|
||||
mapView.setTag(true);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
MapPaddingActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
MapPaddingActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
|
||||
int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);
|
||||
int paddingRight = (int) getResources().getDimension(R.dimen.map_padding_right);
|
||||
int paddingTop = (int) getResources().getDimension(R.dimen.map_padding_top);
|
||||
mapboxMap.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||
int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
|
||||
int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);
|
||||
int paddingRight = (int) getResources().getDimension(R.dimen.map_padding_right);
|
||||
int paddingTop = (int) getResources().getDimension(R.dimen.map_padding_top);
|
||||
mapboxMap.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||
|
||||
moveToBangalore();
|
||||
}
|
||||
moveToBangalore();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -29,13 +28,10 @@ public class VisibilityChangeActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(55.754020, 37.620948), 12), 9000);
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(55.754020, 37.620948), 12), 9000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.offline;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -53,18 +52,8 @@ public class DeleteRegionActivity extends AppCompatActivity implements AdapterVi
|
||||
input.setText(metadata);
|
||||
builder.setView(input);
|
||||
|
||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
delete(region);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("OK", (dialog, which) -> delete(region));
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.offline;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
@@ -17,7 +16,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.offline.OfflineManager;
|
||||
import com.mapbox.mapboxsdk.offline.OfflineRegion;
|
||||
import com.mapbox.mapboxsdk.offline.OfflineRegionError;
|
||||
@@ -80,21 +78,18 @@ public class OfflineActivity extends AppCompatActivity
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setStyleUrl(STYLE_URL);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
Timber.d("Map is ready");
|
||||
OfflineActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
Timber.d("Map is ready");
|
||||
OfflineActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
// Set initial position to UNHQ in NYC
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(40.749851, -73.967966))
|
||||
.zoom(14)
|
||||
.bearing(0)
|
||||
.tilt(0)
|
||||
.build()));
|
||||
}
|
||||
// Set initial position to UNHQ in NYC
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(40.749851, -73.967966))
|
||||
.zoom(14)
|
||||
.bearing(0)
|
||||
.tilt(0)
|
||||
.build()));
|
||||
});
|
||||
|
||||
// The progress bar
|
||||
@@ -102,20 +97,10 @@ public class OfflineActivity extends AppCompatActivity
|
||||
|
||||
// Set up button listeners
|
||||
downloadRegion = (Button) findViewById(R.id.button_download_region);
|
||||
downloadRegion.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
handleDownloadRegion();
|
||||
}
|
||||
});
|
||||
downloadRegion.setOnClickListener(view -> handleDownloadRegion());
|
||||
|
||||
listRegions = (Button) findViewById(R.id.button_list_regions);
|
||||
listRegions.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
handleListRegions();
|
||||
}
|
||||
});
|
||||
listRegions.setOnClickListener(view -> handleListRegions());
|
||||
|
||||
// Set up the OfflineManager
|
||||
offlineManager = OfflineManager.getInstance(this);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.offline;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -57,18 +56,10 @@ public class UpdateMetadataActivity extends AppCompatActivity implements Adapter
|
||||
input.setSelection(metadata.length());
|
||||
builder.setView(input);
|
||||
|
||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
updateMetadata(region, OfflineUtils.convertRegionName(input.getText().toString()));
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("OK", (dialog, which) ->
|
||||
updateMetadata(region, OfflineUtils.convertRegionName(input.getText().toString()))
|
||||
);
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.snapshotter.MapSnapshot;
|
||||
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
@@ -95,17 +94,14 @@ public class MapSnapshotterActivity extends AppCompatActivity {
|
||||
|
||||
MapSnapshotter snapshotter = new MapSnapshotter(MapSnapshotterActivity.this, options);
|
||||
|
||||
snapshotter.start(new MapSnapshotter.SnapshotReadyCallback() {
|
||||
@Override
|
||||
public void onSnapshotReady(MapSnapshot snapshot) {
|
||||
Timber.i("Got the snapshot");
|
||||
ImageView imageView = new ImageView(MapSnapshotterActivity.this);
|
||||
imageView.setImageBitmap(snapshot.getBitmap());
|
||||
grid.addView(
|
||||
imageView,
|
||||
new GridLayout.LayoutParams(GridLayout.spec(row), GridLayout.spec(column))
|
||||
);
|
||||
}
|
||||
snapshotter.start(snapshot -> {
|
||||
Timber.i("Got the snapshot");
|
||||
ImageView imageView = new ImageView(MapSnapshotterActivity.this);
|
||||
imageView.setImageBitmap(snapshot.getBitmap());
|
||||
grid.addView(
|
||||
imageView,
|
||||
new GridLayout.LayoutParams(GridLayout.spec(row), GridLayout.spec(column))
|
||||
);
|
||||
});
|
||||
snapshotters.add(snapshotter);
|
||||
}
|
||||
|
||||
@@ -31,24 +31,21 @@ public class MapSnapshotterReuseActivity extends AppCompatActivity implements Ma
|
||||
|
||||
fab = findViewById(R.id.fab);
|
||||
fab.setVisibility(View.INVISIBLE);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fab.setVisibility(View.INVISIBLE);
|
||||
fab.setOnClickListener(v -> {
|
||||
fab.setVisibility(View.INVISIBLE);
|
||||
|
||||
mapSnapshotter.setStyleUrl(getRandomStyle());
|
||||
if (random.nextInt(2) == 0) {
|
||||
mapSnapshotter.setCameraPosition(getRandomCameraPosition());
|
||||
} else {
|
||||
mapSnapshotter.setRegion(getRandomBounds());
|
||||
}
|
||||
if (random.nextInt(2) == 0) {
|
||||
mapSnapshotter.setSize(512, 512);
|
||||
} else {
|
||||
mapSnapshotter.setSize(256, 256);
|
||||
}
|
||||
mapSnapshotter.start(MapSnapshotterReuseActivity.this);
|
||||
mapSnapshotter.setStyleUrl(getRandomStyle());
|
||||
if (random.nextInt(2) == 0) {
|
||||
mapSnapshotter.setCameraPosition(getRandomCameraPosition());
|
||||
} else {
|
||||
mapSnapshotter.setRegion(getRandomBounds());
|
||||
}
|
||||
if (random.nextInt(2) == 0) {
|
||||
mapSnapshotter.setSize(512, 512);
|
||||
} else {
|
||||
mapSnapshotter.setSize(256, 256);
|
||||
}
|
||||
mapSnapshotter.start(MapSnapshotterReuseActivity.this);
|
||||
});
|
||||
|
||||
mapSnapshotter = new MapSnapshotter(
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.storage.FileSource;
|
||||
import com.mapbox.mapboxsdk.storage.Resource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -47,12 +46,9 @@ public class UrlTransformActivity extends AppCompatActivity {
|
||||
// Get a handle to the file source and set the resource transform
|
||||
FileSource.getInstance(UrlTransformActivity.this).setResourceTransform(new Transform());
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
Timber.i("Map loaded");
|
||||
mapboxMap = map;
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
Timber.i("Map loaded");
|
||||
mapboxMap = map;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.ImageSource;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,15 +2,12 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
@@ -46,13 +43,10 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_building_layer);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
setupBuildings();
|
||||
setupLight();
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
setupBuildings();
|
||||
setupLight();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,24 +67,18 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
|
||||
private void setupLight() {
|
||||
light = mapboxMap.getLight();
|
||||
|
||||
findViewById(R.id.fabLightPosition).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isInitPosition = !isInitPosition;
|
||||
if (isInitPosition) {
|
||||
light.setPosition(new Position(1.5f, 90, 80));
|
||||
} else {
|
||||
light.setPosition(new Position(1.15f, 210, 30));
|
||||
}
|
||||
findViewById(R.id.fabLightPosition).setOnClickListener(v -> {
|
||||
isInitPosition = !isInitPosition;
|
||||
if (isInitPosition) {
|
||||
light.setPosition(new Position(1.5f, 90, 80));
|
||||
} else {
|
||||
light.setPosition(new Position(1.15f, 210, 30));
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.fabLightColor).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isRedColor = !isRedColor;
|
||||
light.setColor(PropertyFactory.colorToRgbaString(isRedColor ? Color.RED : Color.BLUE));
|
||||
}
|
||||
findViewById(R.id.fabLightColor).setOnClickListener(v -> {
|
||||
isRedColor = !isRedColor;
|
||||
light.setColor(PropertyFactory.colorToRgbaString(isRedColor ? Color.RED : Color.BLUE));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -14,7 +13,6 @@ import com.mapbox.mapboxsdk.constants.Style;
|
||||
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.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -56,16 +54,12 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull
|
||||
final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
addBusStopSource();
|
||||
addBusStopCircleLayer();
|
||||
initFloatingActionButtons();
|
||||
isLoadingStyle = false;
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
addBusStopSource();
|
||||
addBusStopCircleLayer();
|
||||
initFloatingActionButtons();
|
||||
isLoadingStyle = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -161,12 +155,9 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
}
|
||||
|
||||
private void loadNewStyle() {
|
||||
mapboxMap.setStyleUrl(getNextStyle(), new MapboxMap.OnStyleLoadedListener() {
|
||||
@Override
|
||||
public void onStyleLoaded(String style) {
|
||||
addBusStop();
|
||||
isLoadingStyle = false;
|
||||
}
|
||||
mapboxMap.setStyleUrl(getNextStyle(), style -> {
|
||||
addBusStop();
|
||||
isLoadingStyle = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@@ -12,7 +11,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -45,56 +43,53 @@ public class CustomSpriteActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
private Point point;
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
private Point point;
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (point == null) {
|
||||
Timber.i("First click -> Car");
|
||||
// Add an icon to reference later
|
||||
mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (point == null) {
|
||||
Timber.i("First click -> Car");
|
||||
// Add an icon to reference later
|
||||
mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
|
||||
|
||||
// Add a source with a geojson point
|
||||
point = Point.fromCoordinates(Position.fromCoordinates(13.400972d, 52.519003d));
|
||||
source = new GeoJsonSource(
|
||||
"point",
|
||||
FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)})
|
||||
);
|
||||
mapboxMap.addSource(source);
|
||||
// Add a source with a geojson point
|
||||
point = Point.fromCoordinates(Position.fromCoordinates(13.400972d, 52.519003d));
|
||||
source = new GeoJsonSource(
|
||||
"point",
|
||||
FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)})
|
||||
);
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// Add a symbol layer that references that point source
|
||||
layer = new SymbolLayer("layer", "point");
|
||||
layer.setProperties(
|
||||
// Set the id of the sprite to use
|
||||
iconImage(CUSTOM_ICON)
|
||||
);
|
||||
// Add a symbol layer that references that point source
|
||||
layer = new SymbolLayer("layer", "point");
|
||||
layer.setProperties(
|
||||
// Set the id of the sprite to use
|
||||
iconImage(CUSTOM_ICON)
|
||||
);
|
||||
|
||||
// lets add a circle below labels!
|
||||
mapboxMap.addLayerBelow(layer, "waterway-label");
|
||||
// lets add a circle below labels!
|
||||
mapboxMap.addLayerBelow(layer, "waterway-label");
|
||||
|
||||
fab.setImageResource(R.drawable.ic_directions_car_black);
|
||||
} else {
|
||||
// Update point
|
||||
point = Point.fromCoordinates(
|
||||
Position.fromCoordinates(point.getCoordinates().getLongitude() + 0.001,
|
||||
point.getCoordinates().getLatitude() + 0.001)
|
||||
);
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)}));
|
||||
fab.setImageResource(R.drawable.ic_directions_car_black);
|
||||
} else {
|
||||
// Update point
|
||||
point = Point.fromCoordinates(
|
||||
Position.fromCoordinates(point.getCoordinates().getLongitude() + 0.001,
|
||||
point.getCoordinates().getLatitude() + 0.001)
|
||||
);
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)}));
|
||||
|
||||
// Move the camera as well
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(
|
||||
point.getCoordinates().getLatitude(), point.getCoordinates().getLongitude())));
|
||||
}
|
||||
// Move the camera as well
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(
|
||||
point.getCoordinates().getLatitude(), point.getCoordinates().getLongitude())));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
@@ -57,22 +56,18 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
mapView.getMapAsync(map -> {
|
||||
// Store for later
|
||||
mapboxMap = map;
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
// Store for later
|
||||
mapboxMap = map;
|
||||
// Add a parks layer
|
||||
addParksLayer();
|
||||
|
||||
// Add a parks layer
|
||||
addParksLayer();
|
||||
// Add debug overlay
|
||||
setupDebugZoomView();
|
||||
|
||||
// Add debug overlay
|
||||
setupDebugZoomView();
|
||||
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
|
||||
}
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
@@ -10,7 +9,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -35,58 +33,55 @@ public class FillExtrusionActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
Polygon domTower = Polygon.fromCoordinates(new double[][][] {
|
||||
new double[][] {
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
},
|
||||
new double[] {
|
||||
5.121227502822875,
|
||||
52.09053901776669
|
||||
},
|
||||
new double[] {
|
||||
5.121484994888306,
|
||||
52.090601641371805
|
||||
},
|
||||
new double[] {
|
||||
5.1213884353637695,
|
||||
52.090766439912635
|
||||
},
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
Polygon domTower = Polygon.fromCoordinates(new double[][][] {
|
||||
new double[][] {
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
},
|
||||
new double[] {
|
||||
5.121227502822875,
|
||||
52.09053901776669
|
||||
},
|
||||
new double[] {
|
||||
5.121484994888306,
|
||||
52.090601641371805
|
||||
},
|
||||
new double[] {
|
||||
5.1213884353637695,
|
||||
52.090766439912635
|
||||
},
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower);
|
||||
map.addSource(source);
|
||||
GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower);
|
||||
map.addSource(source);
|
||||
|
||||
mapboxMap.addLayer(
|
||||
new FillExtrusionLayer("extrusion-layer", source.getId())
|
||||
.withProperties(
|
||||
fillExtrusionHeight(40f),
|
||||
fillExtrusionOpacity(0.5f),
|
||||
fillExtrusionColor(Color.RED)
|
||||
)
|
||||
);
|
||||
mapboxMap.addLayer(
|
||||
new FillExtrusionLayer("extrusion-layer", source.getId())
|
||||
.withProperties(
|
||||
fillExtrusionHeight(40f),
|
||||
fillExtrusionOpacity(0.5f),
|
||||
fillExtrusionColor(Color.RED)
|
||||
)
|
||||
);
|
||||
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(52.09071040847704, 5.12112557888031))
|
||||
.tilt(45.0)
|
||||
.zoom(18)
|
||||
.build()
|
||||
),
|
||||
10000
|
||||
);
|
||||
}
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(52.09071040847704, 5.12112557888031))
|
||||
.tilt(45.0)
|
||||
.zoom(18)
|
||||
.build()
|
||||
),
|
||||
10000
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -24,12 +23,7 @@ public class FillExtrusionStyleTestActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
FillExtrusionStyleTestActivity.this.mapboxMap = mapboxMap;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> FillExtrusionStyleTestActivity.this.mapboxMap = mapboxMap);
|
||||
}
|
||||
|
||||
public MapboxMap getMapboxMap() {
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
|
||||
@@ -50,15 +49,12 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
// noinspection ConstantConditions
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0));
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0));
|
||||
|
||||
// Add a clustered source with some layers
|
||||
addClusteredGeoJsonSource();
|
||||
}
|
||||
// Add a clustered source with some layers
|
||||
addClusteredGeoJsonSource();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
@@ -84,18 +85,15 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
// Store for later
|
||||
mapboxMap = map;
|
||||
mapView.getMapAsync(map -> {
|
||||
// Store for later
|
||||
mapboxMap = map;
|
||||
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
|
||||
|
||||
mapboxMap.setTransitionDuration(250);
|
||||
mapboxMap.setTransitionDelay(50);
|
||||
}
|
||||
mapboxMap.setTransitionDuration(250);
|
||||
mapboxMap.setTransitionDelay(50);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -361,32 +359,29 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
|
||||
private void animateParksSource(final FeatureCollection parks, final int counter) {
|
||||
Handler handler = new Handler(getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timber.d("Updating parks source");
|
||||
// change the source
|
||||
int park = counter < parks.getFeatures().size() - 1 ? counter : 0;
|
||||
|
||||
GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source");
|
||||
|
||||
if (source == null) {
|
||||
Timber.e("Source not found");
|
||||
Toast.makeText(RuntimeStyleActivity.this, "Source not found", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Feature> features = new ArrayList<>();
|
||||
features.add(parks.getFeatures().get(park));
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(features));
|
||||
|
||||
// Re-post
|
||||
animateParksSource(parks, park + 1);
|
||||
handler.postDelayed(() -> {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timber.d("Updating parks source");
|
||||
// change the source
|
||||
int park = counter < parks.getFeatures().size() - 1 ? counter : 0;
|
||||
|
||||
GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source");
|
||||
|
||||
if (source == null) {
|
||||
Timber.e("Source not found");
|
||||
Toast.makeText(RuntimeStyleActivity.this, "Source not found", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Feature> features = new ArrayList<>();
|
||||
features.add(parks.getFeatures().get(park));
|
||||
source.setGeoJson(FeatureCollection.fromFeatures(features));
|
||||
|
||||
// Re-post
|
||||
animateParksSource(parks, park + 1);
|
||||
}, counter == 0 ? 100 : 1000);
|
||||
}
|
||||
|
||||
@@ -486,28 +481,25 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(31, -100), 3));
|
||||
|
||||
Handler handler = new Handler(getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
handler.postDelayed(() -> {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timber.d("Styling filtered fill layer");
|
||||
Timber.d("Styling filtered fill layer");
|
||||
|
||||
FillLayer states = (FillLayer) mapboxMap.getLayer("states");
|
||||
FillLayer states = (FillLayer) mapboxMap.getLayer("states");
|
||||
|
||||
if (states != null) {
|
||||
states.setFilter(eq("name", "Texas"));
|
||||
states.setFillOpacityTransition(new TransitionOptions(2500, 0));
|
||||
states.setFillColorTransition(new TransitionOptions(2500, 0));
|
||||
states.setProperties(
|
||||
fillColor(Color.RED),
|
||||
fillOpacity(0.25f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No states layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (states != null) {
|
||||
states.setFilter(eq("name", "Texas"));
|
||||
states.setFillOpacityTransition(new TransitionOptions(2500, 0));
|
||||
states.setFillColorTransition(new TransitionOptions(2500, 0));
|
||||
states.setProperties(
|
||||
fillColor(Color.RED),
|
||||
fillOpacity(0.25f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No states layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
@@ -517,28 +509,25 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
|
||||
|
||||
Handler handler = new Handler(getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
handler.postDelayed(() -> {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timber.d("Styling filtered line layer");
|
||||
Timber.d("Styling filtered line layer");
|
||||
|
||||
LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
|
||||
LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
|
||||
|
||||
if (counties != null) {
|
||||
counties.setFilter(eq("NAME10", "Washington"));
|
||||
if (counties != null) {
|
||||
counties.setFilter(eq("NAME10", "Washington"));
|
||||
|
||||
counties.setProperties(
|
||||
lineColor(Color.RED),
|
||||
lineOpacity(0.75f),
|
||||
lineWidth(5f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No counties layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
counties.setProperties(
|
||||
lineColor(Color.RED),
|
||||
lineOpacity(0.75f),
|
||||
lineWidth(5f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No counties layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
@@ -548,27 +537,24 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
|
||||
|
||||
Handler handler = new Handler(getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
handler.postDelayed(() -> {
|
||||
if (mapboxMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timber.d("Styling numeric fill layer");
|
||||
Timber.d("Styling numeric fill layer");
|
||||
|
||||
FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
|
||||
FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
|
||||
|
||||
if (regions != null) {
|
||||
regions.setFilter(all(gte("HRRNUM", 200), lt("HRRNUM", 300)));
|
||||
if (regions != null) {
|
||||
regions.setFilter(all(gte("HRRNUM", 200), lt("HRRNUM", 300)));
|
||||
|
||||
regions.setProperties(
|
||||
fillColor(Color.BLUE),
|
||||
fillOpacity(0.5f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No regions layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
regions.setProperties(
|
||||
fillColor(Color.BLUE),
|
||||
fillOpacity(0.5f)
|
||||
);
|
||||
} else {
|
||||
Toast.makeText(RuntimeStyleActivity.this, "No regions layer in this style", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -24,12 +23,7 @@ public class RuntimeStyleTestActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
RuntimeStyleTestActivity.this.mapboxMap = mapboxMap;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> RuntimeStyleTestActivity.this.mapboxMap = mapboxMap);
|
||||
}
|
||||
|
||||
public MapboxMap getMapboxMap() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -32,23 +31,20 @@ public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
|
||||
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
|
||||
mapboxMap.addSource(museums);
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
|
||||
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
|
||||
mapboxMap.addSource(museums);
|
||||
|
||||
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
|
||||
museumsLayer.setSourceLayer("museum-cusco");
|
||||
museumsLayer.setProperties(
|
||||
visibility(VISIBLE),
|
||||
circleRadius(8f),
|
||||
circleColor(Color.argb(1, 55, 148, 179))
|
||||
);
|
||||
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
|
||||
museumsLayer.setSourceLayer("museum-cusco");
|
||||
museumsLayer.setProperties(
|
||||
visibility(VISIBLE),
|
||||
circleRadius(8f),
|
||||
circleColor(Color.argb(1, 55, 148, 179))
|
||||
);
|
||||
|
||||
mapboxMap.addLayer(museumsLayer);
|
||||
}
|
||||
mapboxMap.addLayer(museumsLayer);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,13 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
@@ -39,29 +36,16 @@ public class StyleFileActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_file);
|
||||
fab.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new CreateStyleFileTask(view.getContext(), mapboxMap).execute();
|
||||
}
|
||||
});
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_file);
|
||||
fab.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
|
||||
fab.setOnClickListener(view -> new CreateStyleFileTask(view.getContext(), mapboxMap).execute());
|
||||
|
||||
FloatingActionButton fabStyleJson = (FloatingActionButton) findViewById(R.id.fab_style_json);
|
||||
fabStyleJson.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
|
||||
fabStyleJson.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new LoadStyleFileTask(view.getContext(), mapboxMap).execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
FloatingActionButton fabStyleJson = (FloatingActionButton) findViewById(R.id.fab_style_json);
|
||||
fabStyleJson.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
|
||||
fabStyleJson.setOnClickListener(view -> new LoadStyleFileTask(view.getContext(), mapboxMap).execute());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
@@ -92,19 +91,16 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
}
|
||||
|
||||
private void addSymbolClickListener() {
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
|
||||
if (!features.isEmpty()) {
|
||||
Feature feature = features.get(0);
|
||||
Timber.v("Feature was clicked with data: %s", feature.toJson());
|
||||
Toast.makeText(
|
||||
SymbolGeneratorActivity.this,
|
||||
"hello from: " + feature.getStringProperty(FEATURE_NAME),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
|
||||
if (!features.isEmpty()) {
|
||||
Feature feature = features.get(0);
|
||||
Timber.v("Feature was clicked with data: %s", feature.toJson());
|
||||
Toast.makeText(
|
||||
SymbolGeneratorActivity.this,
|
||||
"hello from: " + feature.getStringProperty(FEATURE_NAME),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -51,43 +50,40 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
|
||||
// Add a image for the makers
|
||||
mapboxMap.addImage(
|
||||
"my-marker-image",
|
||||
BitmapFactory.decodeResource(SymbolLayerActivity.this.getResources(),
|
||||
R.drawable.mapbox_marker_icon_default)
|
||||
);
|
||||
// Add a image for the makers
|
||||
mapboxMap.addImage(
|
||||
"my-marker-image",
|
||||
BitmapFactory.decodeResource(SymbolLayerActivity.this.getResources(),
|
||||
R.drawable.mapbox_marker_icon_default)
|
||||
);
|
||||
|
||||
// Add a source
|
||||
FeatureCollection markers = FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.35673}), featureProperties("Marker 1")),
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.34673}), featureProperties("Marker 2"))
|
||||
});
|
||||
mapboxMap.addSource(new GeoJsonSource(MARKER_SOURCE, markers));
|
||||
// Add a source
|
||||
FeatureCollection markers = FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.35673}), featureProperties("Marker 1")),
|
||||
Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.34673}), featureProperties("Marker 2"))
|
||||
});
|
||||
mapboxMap.addSource(new GeoJsonSource(MARKER_SOURCE, markers));
|
||||
|
||||
// Add the symbol-layer
|
||||
mapboxMap.addLayer(
|
||||
new SymbolLayer(MARKER_LAYER, MARKER_SOURCE)
|
||||
.withProperties(
|
||||
iconImage("my-marker-image"),
|
||||
iconAllowOverlap(true),
|
||||
textField("{title}"),
|
||||
textColor(Color.RED),
|
||||
textSize(10f)
|
||||
)
|
||||
);
|
||||
// Add the symbol-layer
|
||||
mapboxMap.addLayer(
|
||||
new SymbolLayer(MARKER_LAYER, MARKER_SOURCE)
|
||||
.withProperties(
|
||||
iconImage("my-marker-image"),
|
||||
iconAllowOverlap(true),
|
||||
textField("{title}"),
|
||||
textColor(Color.RED),
|
||||
textSize(10f)
|
||||
)
|
||||
);
|
||||
|
||||
// Show
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.35273, 4.91638), 14));
|
||||
// Show
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.35273, 4.91638), 14));
|
||||
|
||||
// Set a click-listener so we can manipulate the map
|
||||
mapboxMap.setOnMapClickListener(SymbolLayerActivity.this);
|
||||
}
|
||||
// Set a click-listener so we can manipulate the map
|
||||
mapboxMap.setOnMapClickListener(SymbolLayerActivity.this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,13 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
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.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -64,14 +61,11 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
updateSource();
|
||||
addLayer();
|
||||
addMapClickListener();
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
updateSource();
|
||||
addLayer();
|
||||
addMapClickListener();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,19 +125,16 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void addMapClickListener() {
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
|
||||
List<Feature> featureList = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
|
||||
if (!featureList.isEmpty()) {
|
||||
Feature feature = featureList.get(0);
|
||||
boolean selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED);
|
||||
isSelected = !selectedNow;
|
||||
updateSource();
|
||||
} else {
|
||||
Timber.e("No features found");
|
||||
}
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
|
||||
List<Feature> featureList = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
|
||||
if (!featureList.isEmpty()) {
|
||||
Feature feature = featureList.get(0);
|
||||
boolean selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED);
|
||||
isSelected = !selectedNow;
|
||||
updateSource();
|
||||
} else {
|
||||
Timber.e("No features found");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.testapp.R;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -56,22 +55,19 @@ public class TextureViewAnimationActivity extends AppCompatActivity {
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
TextureViewAnimationActivity.this.mapboxMap = mapboxMap;
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
TextureViewAnimationActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
setFpsView(mapboxMap);
|
||||
setFpsView(mapboxMap);
|
||||
|
||||
// Animate the map view
|
||||
ObjectAnimator animation = ObjectAnimator.ofFloat(mapView, "rotationY", 0.0f, 360f);
|
||||
animation.setDuration(3600);
|
||||
animation.setRepeatCount(ObjectAnimator.INFINITE);
|
||||
animation.start();
|
||||
// Animate the map view
|
||||
ObjectAnimator animation = ObjectAnimator.ofFloat(mapView, "rotationY", 0.0f, 360f);
|
||||
animation.setDuration(3600);
|
||||
animation.setRepeatCount(ObjectAnimator.INFINITE);
|
||||
animation.start();
|
||||
|
||||
// Start an animation on the map as well
|
||||
flyTo(mapboxMap, 0, 14);
|
||||
}
|
||||
// Start an animation on the map as well
|
||||
flyTo(mapboxMap, 0, 14);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,12 +78,9 @@ public class TextureViewAnimationActivity extends AppCompatActivity {
|
||||
new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
delayed = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delayed = null;
|
||||
flyTo(mapboxMap, place, zoom);
|
||||
}
|
||||
delayed = () -> {
|
||||
delayed = null;
|
||||
flyTo(mapboxMap, place, zoom);
|
||||
};
|
||||
handler.postDelayed(delayed, 2000);
|
||||
}
|
||||
@@ -101,12 +94,7 @@ public class TextureViewAnimationActivity extends AppCompatActivity {
|
||||
|
||||
private void setFpsView(MapboxMap mapboxMap) {
|
||||
final TextView fpsView = (TextView) findViewById(R.id.fpsView);
|
||||
mapboxMap.setOnFpsChangedListener(new MapboxMap.OnFpsChangedListener() {
|
||||
@Override
|
||||
public void onFpsChanged(double fps) {
|
||||
fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps));
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnFpsChangedListener(fps -> fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,12 +11,10 @@ import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@@ -82,13 +80,10 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(int change) {
|
||||
if (change == MapView.DID_FINISH_LOADING_STYLE && mapboxMap != null) {
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
|
||||
setupNavigationView(mapboxMap.getLayers());
|
||||
}
|
||||
mapView.addOnMapChangedListener(change -> {
|
||||
if (change == MapView.DID_FINISH_LOADING_STYLE && mapboxMap != null) {
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
|
||||
setupNavigationView(mapboxMap.getLayers());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -110,25 +105,17 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
|
||||
|
||||
private void setFpsView() {
|
||||
final TextView fpsView = (TextView) findViewById(R.id.fpsView);
|
||||
mapboxMap.setOnFpsChangedListener(new MapboxMap.OnFpsChangedListener() {
|
||||
@Override
|
||||
public void onFpsChanged(double fps) {
|
||||
fpsView.setText(String.format(Locale.US,"FPS: %4.2f", fps));
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnFpsChangedListener(fps -> fpsView.setText(String.format(Locale.US,"FPS: %4.2f", fps)));
|
||||
}
|
||||
|
||||
private void setupNavigationView(List<Layer> layerList) {
|
||||
final LayerListAdapter adapter = new LayerListAdapter(this, layerList);
|
||||
ListView listView = (ListView) findViewById(R.id.listView);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Layer clickedLayer = adapter.getItem(position);
|
||||
toggleLayerVisibility(clickedLayer);
|
||||
closeNavigationView();
|
||||
}
|
||||
listView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Layer clickedLayer = adapter.getItem(position);
|
||||
toggleLayerVisibility(clickedLayer);
|
||||
closeNavigationView();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,44 +135,29 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
|
||||
|
||||
private void setupZoomView() {
|
||||
final TextView textView = (TextView) findViewById(R.id.textZoom);
|
||||
mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition position) {
|
||||
textView.setText(String.format(getString(R.string.debug_zoom), position.zoom));
|
||||
}
|
||||
});
|
||||
mapboxMap.setOnCameraChangeListener(position ->
|
||||
textView.setText(String.format(getString(R.string.debug_zoom), position.zoom)));
|
||||
}
|
||||
|
||||
private void setupDebugChangeView() {
|
||||
FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
|
||||
fabDebug.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
|
||||
mapboxMap.cycleDebugOptions();
|
||||
}
|
||||
fabDebug.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
|
||||
mapboxMap.cycleDebugOptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupStyleChangeView() {
|
||||
FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
|
||||
fabStyles.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
currentStyleIndex++;
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], new MapboxMap.OnStyleLoadedListener() {
|
||||
@Override
|
||||
public void onStyleLoaded(String style) {
|
||||
Timber.d("Style loaded %s", style);
|
||||
}
|
||||
});
|
||||
fabStyles.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
currentStyleIndex++;
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -39,25 +38,17 @@ public class TextureViewResizeActivity extends AppCompatActivity {
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
TextureViewResizeActivity.this.mapboxMap = mapboxMap;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> TextureViewResizeActivity.this.mapboxMap = mapboxMap);
|
||||
}
|
||||
|
||||
private void setupFab() {
|
||||
FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabResize);
|
||||
fabDebug.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapView != null) {
|
||||
View parent = findViewById(R.id.coordinator_layout);
|
||||
int width = parent.getWidth() == mapView.getWidth() ? parent.getWidth() / 2 : parent.getWidth();
|
||||
int height = parent.getHeight() == mapView.getHeight() ? parent.getHeight() / 2 : parent.getHeight();
|
||||
mapView.setLayoutParams(new CoordinatorLayout.LayoutParams(width, height));
|
||||
}
|
||||
fabDebug.setOnClickListener(view -> {
|
||||
if (mapView != null) {
|
||||
View parent = findViewById(R.id.coordinator_layout);
|
||||
int width = parent.getWidth() == mapView.getWidth() ? parent.getWidth() / 2 : parent.getWidth();
|
||||
int height = parent.getHeight() == mapView.getHeight() ? parent.getHeight() / 2 : parent.getHeight();
|
||||
mapView.setLayoutParams(new CoordinatorLayout.LayoutParams(width, height));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
@@ -28,21 +26,15 @@ public class CustomLocationEngineActivity extends BaseLocationActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapboxMap.setLocationSource(MockLocationEngine.getInstance());
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.setLocationSource(MockLocationEngine.getInstance());
|
||||
});
|
||||
|
||||
locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
|
||||
locationToggleFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
enableLocation(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
locationToggleFab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
enableLocation(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,12 +21,9 @@ public class MockLocationEngine extends LocationEngine {
|
||||
private static int counter;
|
||||
|
||||
MockLocationEngine(Location start, Location end) {
|
||||
locationAnimator = new LocationAnimator(start, end, new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
for (LocationEngineListener listener : locationListeners) {
|
||||
listener.onLocationChanged((Location) animation.getAnimatedValue());
|
||||
}
|
||||
locationAnimator = new LocationAnimator(start, end, animation -> {
|
||||
for (LocationEngineListener listener : locationListeners) {
|
||||
listener.onLocationChanged((Location) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
|
||||
|
||||
@@ -50,12 +49,9 @@ public class MyLocationDrawableActivity extends BaseLocationActivity implements
|
||||
parent.addView(mapView);
|
||||
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
toggleGps(true);
|
||||
}
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
toggleGps(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
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.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -37,80 +36,65 @@ public class MyLocationTintActivity extends BaseLocationActivity implements Loca
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
|
||||
// enable location updates
|
||||
toggleGps(!mapboxMap.isMyLocationEnabled());
|
||||
// enable location updates
|
||||
toggleGps(!mapboxMap.isMyLocationEnabled());
|
||||
|
||||
// add some padding
|
||||
final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
|
||||
myLocationViewSettings.setPadding(0, 500, 0, 0);
|
||||
// add some padding
|
||||
final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
|
||||
myLocationViewSettings.setPadding(0, 500, 0, 0);
|
||||
|
||||
// enable tracking
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setDismissLocationTrackingOnGesture(false);
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
// enable tracking
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setDismissLocationTrackingOnGesture(false);
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
|
||||
// handle default button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.default_user_dot_coloring_button,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
}
|
||||
});
|
||||
// handle default button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.default_user_dot_coloring_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
// handle tint user dot button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.tint_user_dot_button,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
}
|
||||
});
|
||||
// handle tint user dot button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.tint_user_dot_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
// handle tint accuracy ring button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_accuracy_ring_tint_button,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
}
|
||||
});
|
||||
// handle tint accuracy ring button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_accuracy_ring_tint_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_dot_transparent_button,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_dot_transparent_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import timber.log.Timber;
|
||||
@@ -27,20 +25,12 @@ public class MyLocationToggleActivity extends BaseLocationActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(map -> mapboxMap = map);
|
||||
|
||||
locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
|
||||
locationToggleFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapboxMap != null) {
|
||||
toggleGps(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
locationToggleFab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
toggleGps(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,41 +125,35 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
|
||||
bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
setCheckBoxes();
|
||||
|
||||
mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() {
|
||||
@Override
|
||||
public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) {
|
||||
locationSpinner.setOnItemSelectedListener(null);
|
||||
switch (myLocationTrackingMode) {
|
||||
case MyLocationTracking.TRACKING_NONE:
|
||||
locationSpinner.setSelection(TRACKING_NONE_INDEX);
|
||||
break;
|
||||
case MyLocationTracking.TRACKING_FOLLOW:
|
||||
locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
|
||||
break;
|
||||
}
|
||||
locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
mapboxMap.setOnMyLocationTrackingModeChangeListener(myLocationTrackingMode -> {
|
||||
locationSpinner.setOnItemSelectedListener(null);
|
||||
switch (myLocationTrackingMode) {
|
||||
case MyLocationTracking.TRACKING_NONE:
|
||||
locationSpinner.setSelection(TRACKING_NONE_INDEX);
|
||||
break;
|
||||
case MyLocationTracking.TRACKING_FOLLOW:
|
||||
locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
|
||||
break;
|
||||
}
|
||||
locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
});
|
||||
|
||||
mapboxMap.setOnMyBearingTrackingModeChangeListener(new MapboxMap.OnMyBearingTrackingModeChangeListener() {
|
||||
@Override
|
||||
public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) {
|
||||
bearingSpinner.setOnItemSelectedListener(null);
|
||||
switch (myBearingTrackingMode) {
|
||||
case MyBearingTracking.NONE:
|
||||
bearingSpinner.setSelection(BEARING_NONE_INDEX);
|
||||
break;
|
||||
mapboxMap.setOnMyBearingTrackingModeChangeListener(myBearingTrackingMode -> {
|
||||
bearingSpinner.setOnItemSelectedListener(null);
|
||||
switch (myBearingTrackingMode) {
|
||||
case MyBearingTracking.NONE:
|
||||
bearingSpinner.setSelection(BEARING_NONE_INDEX);
|
||||
break;
|
||||
|
||||
case MyBearingTracking.GPS:
|
||||
bearingSpinner.setSelection(BEARING_GPS_INDEX);
|
||||
break;
|
||||
case MyBearingTracking.GPS:
|
||||
bearingSpinner.setSelection(BEARING_GPS_INDEX);
|
||||
break;
|
||||
|
||||
case MyBearingTracking.COMPASS:
|
||||
bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
|
||||
break;
|
||||
}
|
||||
bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
case MyBearingTracking.COMPASS:
|
||||
bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
|
||||
break;
|
||||
}
|
||||
bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import android.widget.TextView;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.FontCache;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@@ -126,14 +125,9 @@ public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
||||
public void setSections(Section[] sections) {
|
||||
this.sections.clear();
|
||||
|
||||
Arrays.sort(sections, new Comparator<Section>() {
|
||||
@Override
|
||||
public int compare(Section section, Section section1) {
|
||||
return (section.firstPosition == section1.firstPosition)
|
||||
? 0
|
||||
: ((section.firstPosition < section1.firstPosition) ? -1 : 1);
|
||||
}
|
||||
});
|
||||
Arrays.sort(sections, (section, section1) -> (section.firstPosition == section1.firstPosition)
|
||||
? 0
|
||||
: ((section.firstPosition < section1.firstPosition) ? -1 : 1));
|
||||
|
||||
int offset = 0;
|
||||
for (Section section : sections) {
|
||||
|
||||
@@ -2,18 +2,16 @@ package com.mapbox.mapboxsdk.testapp.model.other;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class OfflineDownloadRegionDialog extends DialogFragment {
|
||||
|
||||
public interface DownloadRegionDialogListener {
|
||||
@@ -39,18 +37,10 @@ public class OfflineDownloadRegionDialog extends DialogFragment {
|
||||
builder.setTitle("Choose a name for the region")
|
||||
.setIcon(R.drawable.ic_airplanemode_active_black)
|
||||
.setView(regionNameEdit)
|
||||
.setPositiveButton("Start", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String regionName = regionNameEdit.getText().toString();
|
||||
listener.onDownloadRegionDialogPositiveClick(regionName);
|
||||
}
|
||||
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Timber.d("Download cancelled.");
|
||||
}
|
||||
});
|
||||
.setPositiveButton("Start", (dialog, which) -> {
|
||||
String regionName = regionNameEdit.getText().toString();
|
||||
listener.onDownloadRegionDialogPositiveClick(regionName);
|
||||
}).setNegativeButton("Cancel", (dialog, which) -> Timber.d("Download cancelled."));
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.other;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class OfflineListRegionsDialog extends DialogFragment {
|
||||
|
||||
public static final String ITEMS = "ITEMS";
|
||||
@@ -29,18 +28,8 @@ public class OfflineListRegionsDialog extends DialogFragment {
|
||||
|
||||
builder.setTitle("List of offline regions")
|
||||
.setIcon(R.drawable.ic_airplanemode_active_black)
|
||||
.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Timber.d("Selected item: %s", which);
|
||||
}
|
||||
})
|
||||
.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Timber.d("Dialog dismissed");
|
||||
}
|
||||
});
|
||||
.setItems(items, (dialog, which) -> Timber.d("Selected item: %s", which))
|
||||
.setPositiveButton("Accept", (dialog, which) -> Timber.d("Dialog dismissed"));
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.mapbox.mapboxsdk.testapp.utils;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class FontCache {
|
||||
|
||||
private static Hashtable<String, Typeface> fontCache = new Hashtable<>();
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.mapbox.mapboxsdk.testapp.utils;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity.JSON_CHARSET;
|
||||
import static com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity.JSON_FIELD_REGION_NAME;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user