summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-03-09 17:46:00 -0500
committerTobrun <tobrun.van.nuland@gmail.com>2016-03-09 17:46:00 -0500
commit808bf7004a4360a4cc7095f97c235c92d3679f8b (patch)
treef5225f5785f057923cfa5bd5c4806f5958b56e88
parent7cceca4b4576c21c315b445889bad770e7dc4e53 (diff)
downloadqtlocation-mapboxgl-808bf7004a4360a4cc7095f97c235c92d3679f8b.tar.gz
[android] #4076 - MapboxMapOptions fix
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java163
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java135
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivity.java29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxMapActivity.java112
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/SupportMapFragmentActivity.java56
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java22
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_mapboxmap.xml9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_mapboxmap.xml24
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java62
14 files changed, 468 insertions, 172 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index ec61a767c2..a31da56f42 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -13,7 +13,6 @@ import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
-import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PointF;
@@ -39,7 +38,6 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
-import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -112,8 +110,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public class MapView extends FrameLayout {
- private static final String TAG = "MapView";
-
private MapboxMap mMapboxMap;
private List<Icon> mIcons;
@@ -151,7 +147,7 @@ public class MapView extends FrameLayout {
@UiThread
public MapView(@NonNull Context context) {
super(context);
- initialize(context, null);
+ initialize(context, MapboxMapOptions.createFromAttributes(context, null));
}
@UiThread
@@ -172,7 +168,7 @@ public class MapView extends FrameLayout {
initialize(context, options);
}
- private void initialize(@NonNull Context context, @Nullable MapboxMapOptions options) {
+ private void initialize(@NonNull Context context, @NonNull MapboxMapOptions options) {
mInitialLoad = true;
mOnMapChangedListener = new CopyOnWriteArrayList<>();
mMapboxMap = new MapboxMap(this);
@@ -209,11 +205,6 @@ public class MapView extends FrameLayout {
mRotateGestureDetector = new RotateGestureDetector(context, new RotateGestureListener());
mShoveGestureDetector = new ShoveGestureDetector(context, new ShoveGestureListener());
- // Shows the zoom controls
- if (!context.getPackageManager()
- .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
- mMapboxMap.getUiSettings().setZoomControlsEnabled(true);
- }
mZoomButtonsController = new ZoomButtonsController(this);
mZoomButtonsController.setZoomSpeed(MapboxConstants.ANIMATION_DURATION);
mZoomButtonsController.setOnZoomListener(new OnZoomListener());
@@ -235,69 +226,69 @@ public class MapView extends FrameLayout {
mScreenDensity = context.getResources().getDisplayMetrics().density;
-// // Load the attributes
-// TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapView, 0, 0);
-// try {
-// // Debug mode
-// mMapboxMap.setDebugActive(typedArray.getBoolean(R.styleable.MapView_debug_active, false));
-//
-// // Move camera
-// CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
-// mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
-//
-// // Access token
-// String accessToken = typedArray.getString(R.styleable.MapView_access_token);
-// if (accessToken != null) {
-// setAccessToken(typedArray.getString(R.styleable.MapView_access_token));
-// }
-//
-// // Style url
-// String styleUrl = typedArray.getString(R.styleable.MapView_style_url);
-// if (styleUrl != null) {
-// mMapboxMap.setStyleUrl(styleUrl);
-// }
-//
-// // Enable gestures
-// UiSettings uiSettings = mMapboxMap.getUiSettings();
-// uiSettings.setZoomGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_enabled, true));
-// uiSettings.setScrollGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_scroll_enabled, true));
-// uiSettings.setRotateGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_rotate_enabled, true));
-// uiSettings.setTiltGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_tilt_enabled, true));
-// uiSettings.setZoomControlsEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_controls_enabled, false));
-//
-// // Zoom
-// uiSettings.setMaxZoom(typedArray.getFloat(R.styleable.MapView_zoom_max, (float) MapboxConstants.MAXIMUM_ZOOM));
-// uiSettings.setMinZoom(typedArray.getFloat(R.styleable.MapView_zoom_min, (float) MapboxConstants.MINIMUM_ZOOM));
-//
-// // Compass
-// uiSettings.setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compass_enabled, true));
-// uiSettings.setCompassGravity(typedArray.getInt(R.styleable.MapView_compass_gravity, Gravity.TOP | Gravity.END));
-// uiSettings.setCompassMargins((int) (typedArray.getDimension(R.styleable.MapView_compass_margin_left, DIMENSION_TEN_DP) * mScreenDensity)
-// , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_top, DIMENSION_TEN_DP * mScreenDensity))
-// , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_right, DIMENSION_TEN_DP * mScreenDensity))
-// , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_bottom, DIMENSION_TEN_DP * mScreenDensity)));
-//
-// // Logo
-// uiSettings.setLogoEnabled(typedArray.getBoolean(R.styleable.MapView_logo_visibility, true));
-// uiSettings.setLogoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
-// uiSettings.setLogoMargins((int) (typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP) * mScreenDensity));
-//
-// // Attribution
-// uiSettings.setAttributionEnabled(typedArray.getBoolean(R.styleable.MapView_attribution_visibility, true));
-// uiSettings.setAttributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
-// uiSettings.setAttributionMargins((int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTY_SIX_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * mScreenDensity));
-//
-// // User location
-// mMapboxMap.setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
-// } finally {
-// typedArray.recycle();
-// }
+ setInitialState(options);
+
+ // Shows the zoom controls
+ if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
+ mMapboxMap.getUiSettings().setZoomControlsEnabled(true);
+ }
+ }
+
+ private void setInitialState(MapboxMapOptions options) {
+ mMapboxMap.setDebugActive(options.getDebugActive());
+
+ CameraPosition position = options.getCamera();
+ if (position != null) {
+ mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(position));
+ }
+
+ String accessToken = options.getAccessToken();
+ if (!TextUtils.isEmpty(accessToken)) {
+ mMapboxMap.setAccessToken(accessToken);
+ }
+
+ String style = options.getStyle();
+ if (!TextUtils.isEmpty(style)) {
+ mMapboxMap.setStyleUrl(style);
+ }
+
+ mMapboxMap.setMyLocationEnabled(options.getLocationEnabled());
+
+ // Enable gestures
+ UiSettings uiSettings = mMapboxMap.getUiSettings();
+ uiSettings.setZoomGesturesEnabled(options.getZoomGesturesEnabled());
+ uiSettings.setScrollGesturesEnabled(options.getScrollGesturesEnabled());
+ uiSettings.setRotateGesturesEnabled(options.getRotateGesturesEnabled());
+ uiSettings.setTiltGesturesEnabled(options.getTiltGesturesEnabled());
+ uiSettings.setZoomControlsEnabled(options.getZoomControlsEnabled());
+
+ // Zoom
+ uiSettings.setMaxZoom(options.getMaxZoom());
+ uiSettings.setMinZoom(options.getMinZoom());
+
+ // Compass
+ uiSettings.setCompassEnabled(options.getCompassEnabled());
+ uiSettings.setCompassGravity(options.getCompassGravity());
+ int[] compassMargins = options.getCompassMargins();
+ if (compassMargins != null) {
+ uiSettings.setCompassMargins(compassMargins[0], compassMargins[1], compassMargins[2], compassMargins[3]);
+ }
+
+ // Logo
+ uiSettings.setLogoEnabled(options.getLogoEnabled());
+ uiSettings.setLogoGravity(options.getLogoGravity());
+ int[] logoMargins = options.getLogoMargins();
+ if (logoMargins != null) {
+ uiSettings.setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
+ }
+
+ // Attribution
+ uiSettings.setAttributionEnabled(options.getAttributionEnabled());
+ uiSettings.setAttributionGravity(options.getAttributionGravity());
+ int[] attributionMargins = options.getAttributionMargins();
+ if (attributionMargins != null) {
+ uiSettings.setAttributionMargins(attributionMargins[0], attributionMargins[1], attributionMargins[2], attributionMargins[3]);
+ }
}
//
@@ -359,7 +350,6 @@ public class MapView extends FrameLayout {
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT)
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM));
-
mMapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
mMapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
setAccessToken(savedInstanceState.getString(MapboxConstants.STATE_ACCESS_TOKEN));
@@ -435,7 +425,6 @@ public class MapView extends FrameLayout {
outState.putLong(MapboxConstants.STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration());
outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, mMapboxMap.isMyLocationEnabled());
-
// TrackingSettings
TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings();
outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, trackingSettings.getMyLocationTrackingMode());
@@ -809,12 +798,9 @@ public class MapView extends FrameLayout {
* You must set a valid access token before you call {@link MapView#onCreate(Bundle)}
* or an exception will be thrown.
* </p>
- * You can use {@link ApiAccess#getToken(Context)} to load an access token from your
- * application's manifest.
*
* @param accessToken Your public Mapbox access token.
* @see MapView#onCreate(Bundle)
- * @see ApiAccess#getToken(Context)
*/
@UiThread
public void setAccessToken(@NonNull String accessToken) {
@@ -863,7 +849,7 @@ public class MapView extends FrameLayout {
}
}
} catch (Exception e) {
- Log.w(TAG, "Error checking for Telemetry Service Config: " + e);
+ Log.w(MapboxConstants.TAG, "Error checking for Telemetry Service Config: " + e);
}
throw new TelemetryServiceNotConfiguredException();
}
@@ -954,12 +940,12 @@ public class MapView extends FrameLayout {
return;
}
if (updatedMarker == null) {
- Log.w(TAG, "marker was null, doing nothing");
+ Log.w(MapboxConstants.TAG, "marker was null, doing nothing");
return;
}
if (updatedMarker.getId() == -1) {
- Log.w(TAG, "marker has an id of -1, possibly was not added yet, doing nothing");
+ Log.w(MapboxConstants.TAG, "marker has an id of -1, possibly was not added yet, doing nothing");
}
ensureIconLoaded(updatedMarker);
@@ -1048,7 +1034,7 @@ public class MapView extends FrameLayout {
}
if (bbox == null) {
- Log.w(TAG, "bbox was null, so just returning null");
+ Log.w(MapboxConstants.TAG, "bbox was null, so just returning null");
return null;
}
@@ -1753,7 +1739,6 @@ public class MapView extends FrameLayout {
PointF centerPoint = mUserLocationView.getMarkerScreenPoint();
mNativeMapView.scaleBy(detector.getScaleFactor(), centerPoint.x / mScreenDensity, centerPoint.y / mScreenDensity);
}
- trackGestureEvent(MapboxEvent.GESTURE_QUICK_ZOOM, detector.getFocusX(), detector.getFocusY());
}
return true;
}
@@ -1841,7 +1826,7 @@ public class MapView extends FrameLayout {
}
// This class handles a vertical two-finger shove. (If you place two fingers on screen with
- // less than a 20 degree angle between them, this will detect movement on the Y-axis.)
+// less than a 20 degree angle between them, this will detect movement on the Y-axis.)
private class ShoveGestureListener implements ShoveGestureDetector.OnShoveGestureListener {
long mBeginTime = 0;
@@ -1912,7 +1897,7 @@ public class MapView extends FrameLayout {
}
// This class handles input events from the zoom control buttons
- // Zoom controls allow single touch only devices to zoom in and out
+// Zoom controls allow single touch only devices to zoom in and out
private class OnZoomListener implements ZoomButtonsController.OnZoomListener {
// Not used
@@ -2219,9 +2204,9 @@ public class MapView extends FrameLayout {
}
}
- //
- // Connectivity events
- //
+//
+// Connectivity events
+//
// This class handles connectivity changes
private class ConnectivityReceiver extends BroadcastReceiver {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index fd582c2c8c..5aff0d6569 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -4,6 +4,8 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -27,11 +29,11 @@ public class MapboxMapOptions implements Parcelable {
private int compassMargins[];
private boolean logoEnabled = true;
- private int logoGravity;
+ private int logoGravity = Gravity.BOTTOM | Gravity.START;
private int logoMargins[];
private boolean attributionEnabled = true;
- private int attributionGravity;
+ private int attributionGravity = Gravity.BOTTOM;
private int attributionMargins[];
private float minZoom = MapboxConstants.MINIMUM_ZOOM;
@@ -40,8 +42,8 @@ public class MapboxMapOptions implements Parcelable {
private boolean rotateGesturesEnabled = true;
private boolean scrollGesturesEnabled = true;
private boolean tiltGesturesEnabled = true;
- private boolean zoomControlsEnabled = true;
private boolean zoomGesturesEnabled = true;
+ private boolean zoomControlsEnabled = false;
private boolean locationEnabled;
@@ -54,17 +56,35 @@ public class MapboxMapOptions implements Parcelable {
private MapboxMapOptions(Parcel in) {
cameraPosition = in.readParcelable(CameraPosition.class.getClassLoader());
debugActive = in.readByte() != 0;
+
compassEnabled = in.readByte() != 0;
+ compassGravity = in.readInt();
+ compassMargins = in.createIntArray();
+
+ logoEnabled = in.readByte() != 0;
+ logoGravity = in.readInt();
+ logoMargins = in.createIntArray();
+
+ attributionEnabled = in.readByte() != 0;
+ attributionGravity = in.readInt();
+ attributionMargins = in.createIntArray();
+
+ minZoom = in.readFloat();
+ maxZoom = in.readFloat();
+
rotateGesturesEnabled = in.readByte() != 0;
scrollGesturesEnabled = in.readByte() != 0;
tiltGesturesEnabled = in.readByte() != 0;
zoomControlsEnabled = in.readByte() != 0;
zoomGesturesEnabled = in.readByte() != 0;
+
+ locationEnabled = in.readByte() != 0;
+
style = in.readString();
accessToken = in.readString();
}
- public static MapboxMapOptions createFromAttributes(Context context, AttributeSet attrs) {
+ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @Nullable AttributeSet attrs) {
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
float screenDensity = context.getResources().getDisplayMetrics().density;
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapView, 0, 0);
@@ -91,30 +111,25 @@ public class MapboxMapOptions implements Parcelable {
, ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_top, DIMENSION_TEN_DP * screenDensity))
, ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_right, DIMENSION_TEN_DP * screenDensity))
, ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_bottom, DIMENSION_TEN_DP * screenDensity))});
-//
-// // Logo
- uiSettings.setLogoEnabled(typedArray.getBoolean(R.styleable.MapView_logo_visibility, true));
- uiSettings.setLogoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
- uiSettings.setLogoMargins((int) (typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP) * mScreenDensity)
- , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP) * mScreenDensity)
- , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP) * mScreenDensity)
- , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP) * mScreenDensity));
-//
-// // Attribution
-// uiSettings.setAttributionEnabled(typedArray.getBoolean(R.styleable.MapView_attribution_visibility, true));
-// uiSettings.setAttributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
-// uiSettings.setAttributionMargins((int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTY_SIX_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP) * mScreenDensity)
-// , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * mScreenDensity));
-//
-// // User location
-// mMapboxMap.setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
+
+ mapboxMapOptions.logoEnabled(typedArray.getBoolean(R.styleable.MapView_logo_visibility, true));
+ mapboxMapOptions.logoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
+ mapboxMapOptions.logoMargins(new int[]{(int) (typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP) * screenDensity)});
+
+ mapboxMapOptions.attributionEnabled(typedArray.getBoolean(R.styleable.MapView_attribution_visibility, true));
+ mapboxMapOptions.attributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
+ mapboxMapOptions.attributionMargins(new int[]{(int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTY_SIX_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP) * screenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * screenDensity)});
+
+ mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
} finally {
typedArray.recycle();
}
-
-
return mapboxMapOptions;
}
@@ -163,21 +178,36 @@ public class MapboxMapOptions implements Parcelable {
return this;
}
- public MapboxMapOptions logoEnabled(boolean enabled){
- logoEnabled = enabled;
- return this
+ public MapboxMapOptions logoEnabled(boolean enabled) {
+ logoEnabled = enabled;
+ return this;
}
- public MapboxMapOptions logoGravity(int gravity){
+ public MapboxMapOptions logoGravity(int gravity) {
logoGravity = gravity;
return this;
}
- public MapboxMapOptions logoMargins(int[]margins){
+ public MapboxMapOptions logoMargins(int[] margins) {
logoMargins = margins;
return this;
}
+ public MapboxMapOptions attributionEnabled(boolean enabled) {
+ attributionEnabled = enabled;
+ return this;
+ }
+
+ public MapboxMapOptions attributionGravity(int gravity) {
+ attributionGravity = gravity;
+ return this;
+ }
+
+ public MapboxMapOptions attributionMargins(int[] margins) {
+ attributionMargins = margins;
+ return this;
+ }
+
public MapboxMapOptions rotateGesturesEnabled(boolean enabled) {
rotateGesturesEnabled = enabled;
return this;
@@ -203,6 +233,11 @@ public class MapboxMapOptions implements Parcelable {
return this;
}
+ public MapboxMapOptions locationEnabled(boolean locationEnabled) {
+ this.locationEnabled = locationEnabled;
+ return this;
+ }
+
public CameraPosition getCamera() {
return cameraPosition;
}
@@ -255,7 +290,7 @@ public class MapboxMapOptions implements Parcelable {
return scrollGesturesEnabled;
}
- public boolean getTitltGesturesEnabeld() {
+ public boolean getTiltGesturesEnabled() {
return tiltGesturesEnabled;
}
@@ -267,6 +302,26 @@ public class MapboxMapOptions implements Parcelable {
return zoomGesturesEnabled;
}
+ public boolean getAttributionEnabled() {
+ return attributionEnabled;
+ }
+
+ public int getAttributionGravity() {
+ return attributionGravity;
+ }
+
+ public int[] getAttributionMargins() {
+ return attributionMargins;
+ }
+
+ public boolean getLocationEnabled() {
+ return locationEnabled;
+ }
+
+ public boolean getDebugActive() {
+ return debugActive;
+ }
+
public static final Parcelable.Creator<MapboxMapOptions> CREATOR
= new Parcelable.Creator<MapboxMapOptions>() {
public MapboxMapOptions createFromParcel(Parcel in) {
@@ -287,12 +342,30 @@ public class MapboxMapOptions implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(cameraPosition, flags);
dest.writeByte((byte) (debugActive ? 1 : 0));
+
dest.writeByte((byte) (compassEnabled ? 1 : 0));
+ dest.writeInt(compassGravity);
+ dest.writeIntArray(compassMargins);
+
+ dest.writeByte((byte) (logoEnabled ? 1 : 0));
+ dest.writeInt(logoGravity);
+ dest.writeIntArray(logoMargins);
+
+ dest.writeByte((byte) (attributionEnabled ? 1 : 0));
+ dest.writeInt(attributionGravity);
+ dest.writeIntArray(attributionMargins);
+
+ dest.writeFloat(minZoom);
+ dest.writeFloat(maxZoom);
+
dest.writeByte((byte) (rotateGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (scrollGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (tiltGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (zoomControlsEnabled ? 1 : 0));
dest.writeByte((byte) (zoomGesturesEnabled ? 1 : 0));
+
+ dest.writeByte((byte) (locationEnabled ? 1 : 0));
+
dest.writeString(style);
dest.writeString(accessToken);
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index 8fdd590abe..0d2b78acf8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -24,6 +24,9 @@
</intent-filter>
</activity>
<activity
+ android:name=".MapboxMapActivity"
+ android:label="@string/action_mapboxmap" />
+ <activity
android:name=".LatLngBoundsActivity"
android:label="@string/activity_visible_coordinate_bounds" />
<activity
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
index edc52dca1b..45d6d33774 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
@@ -358,6 +358,10 @@ public class MainActivity extends AppCompatActivity {
uiSettings.setCompassEnabled(!uiSettings.isCompassEnabled());
return true;
+ case R.id.action_mapboxmap:
+ startActivity(new Intent(getApplicationContext(), MapboxMapActivity.class));
+ return true;
+
case R.id.action_info_window_adapter:
startActivity(new Intent(getApplicationContext(), InfoWindowAdapterActivity.class));
return true;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivity.java
index d3555a539e..d2fc7b6713 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivity.java
@@ -40,9 +40,28 @@ public class MapFragmentActivity extends AppCompatActivity {
MapboxMapOptions options = new MapboxMapOptions();
options.accessToken(ApiAccess.getToken(this));
- options.styleUrl(Style.SATELLITE);
+ options.styleUrl(Style.SATELLITE_STREETS);
- transaction.add(R.id.fragment_container, mapFragment = MapFragment.newInstance(options), "com.mapbox.map");
+ options.scrollGesturesEnabled(false);
+ options.zoomGesturesEnabled(false);
+ options.tiltGesturesEnabled(false);
+ options.rotateGesturesEnabled(false);
+
+ options.debugActive(false);
+ options.compassEnabled(false);
+ options.attributionEnabled(false);
+ options.logoEnabled(false);
+
+ options.minZoom(9);
+ options.maxZoom(11);
+ options.camera(new CameraPosition.Builder()
+ .target(new LatLng(48.861431, 2.334166))
+ .zoom(9)
+ .build());
+
+ mapFragment = MapFragment.newInstance(options);
+
+ transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
transaction.commit();
} else {
mapFragment = (MapFragment) getFragmentManager().findFragmentByTag("com.mapbox.map");
@@ -51,11 +70,7 @@ public class MapFragmentActivity extends AppCompatActivity {
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(new LatLng(48.861431, 2.334166))
- .zoom(10)
- .build()));
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2), 3500);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxMapActivity.java
new file mode 100644
index 0000000000..ddab530106
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxMapActivity.java
@@ -0,0 +1,112 @@
+package com.mapbox.mapboxsdk.testapp;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+
+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.maps.OnMapReadyCallback;
+import com.mapbox.mapboxsdk.constants.Style;
+import com.mapbox.mapboxsdk.testapp.utils.ApiAccess;
+import com.mapbox.mapboxsdk.maps.MapView;
+
+public class MapboxMapActivity extends AppCompatActivity {
+
+ private MapView mMapView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_mapboxmap);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
+
+ mMapView = (MapView) findViewById(R.id.mapView);
+ mMapView.setAccessToken(ApiAccess.getToken(this));
+ mMapView.setStyle(Style.SATELLITE_STREETS);
+ mMapView.onCreate(savedInstanceState);
+
+ mMapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(new LatLng(43.876550, -103.454791))
+ .zoom(14)
+ .build()));
+ }
+ });
+
+ Snackbar.make(findViewById(android.R.id.content),
+ "Demo MapboxMap API",
+ Snackbar.LENGTH_INDEFINITE).show();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mMapView.onStart();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mMapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mMapView.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mMapView.onStop();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mMapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mMapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mMapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/SupportMapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/SupportMapFragmentActivity.java
index 572c2260c5..956a4c1fca 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/SupportMapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/SupportMapFragmentActivity.java
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -12,9 +11,11 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapFragment;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
-import com.mapbox.mapboxsdk.maps.SupportMapFragment;
+import com.mapbox.mapboxsdk.testapp.utils.ApiAccess;
public class SupportMapFragmentActivity extends AppCompatActivity {
@@ -32,28 +33,45 @@ public class SupportMapFragmentActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- SupportMapFragment mapFragment;
+ MapFragment mapFragment;
if (savedInstanceState == null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-// transaction.add(R.id.fragment_container, mapFragment = SupportMapFragment.newInstance(), "com.mapbox.map");
+ android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ MapboxMapOptions options = new MapboxMapOptions();
+ options.accessToken(ApiAccess.getToken(this));
+ options.styleUrl(Style.SATELLITE_STREETS);
+
+ options.scrollGesturesEnabled(false);
+ options.zoomGesturesEnabled(false);
+ options.tiltGesturesEnabled(false);
+ options.rotateGesturesEnabled(false);
+
+ options.debugActive(false);
+ options.compassEnabled(false);
+ options.attributionEnabled(false);
+ options.logoEnabled(false);
+
+ options.minZoom(9);
+ options.maxZoom(11);
+ options.camera(new CameraPosition.Builder()
+ .target(new LatLng(48.861431, 2.334166))
+ .zoom(9)
+ .build());
+
+ mapFragment = MapFragment.newInstance(options);
+
+ transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
transaction.commit();
} else {
- mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
+ mapFragment = (MapFragment) getFragmentManager().findFragmentByTag("com.mapbox.map");
}
-// mapFragment.getMapAsync(new OnMapReadyCallback() {
-// @Override
-// public void onMapReady(@NonNull MapboxMap mapboxMap) {
-// mapboxMap.setStyleUrl(Style.SATELLITE_STREETS);
-// mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
-// new CameraPosition.Builder()
-// .target(new LatLng(48.861431, 2.334166))
-// .zoom(10)
-// .bearing(0)
-// .tilt(0)
-// .build()));
-// }
-// });
+ mapFragment.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2), 3500);
+ }
+ });
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
index bfce95b393..b178b24c25 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
@@ -9,16 +9,13 @@ import android.view.MenuItem;
import com.mapbox.mapboxsdk.camera.CameraPosition;
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.utils.ApiAccess;
-import com.mapbox.mapboxsdk.maps.MapView;
public class TiltActivity extends AppCompatActivity {
- private final static LatLng WASHINGTON_DC = new LatLng(38.90252, -77.02291);
-
private MapView mMapView;
@Override
@@ -35,27 +32,14 @@ public class TiltActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- // Set up the map
mMapView = (MapView) findViewById(R.id.tiltMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
-
- // Move camera to Washington DC
- CameraPosition normalCameraPosition = new CameraPosition.Builder()
- .target(WASHINGTON_DC)
- .zoom(11)
- .build();
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(normalCameraPosition));
-
- // Animate camera tilting
- CameraPosition tiltedCameraPosition = new CameraPosition.Builder()
- .target(WASHINGTON_DC)
- .zoom(11)
- .tilt(45.0f)
- .build();
+ // initial position has been set in R.layout.activity_tilt
+ CameraPosition tiltedCameraPosition = new CameraPosition.Builder().tilt(45.0f).build();
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(tiltedCameraPosition), 10000);
}
});
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_mapboxmap.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_mapboxmap.xml
new file mode 100644
index 0000000000..3482fa9dbc
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_mapboxmap.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M12,11.55C9.64,9.35 6.48,8 3,8v11c3.48,0 6.64,1.35 9,3.55 2.36,-2.19 5.52,-3.55 9,-3.55V8c-3.48,0 -6.64,1.35 -9,3.55zM12,8c1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3 1.34,3 3,3z"/>
+</vector>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_mapboxmap.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_mapboxmap.xml
new file mode 100644
index 0000000000..eccd3ea8eb
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_mapboxmap.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="@color/primary"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+ <com.mapbox.mapboxsdk.maps.MapView
+ android:id="@+id/mapView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:style_url="@string/style_mapbox_streets"
+ app:center_latitude="38.897705003219784"
+ app:center_longitude="-77.03655168667463"
+ app:zoom="15" />
+
+</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
index a82e80353d..eae320c750 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@@ -14,6 +15,10 @@
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/tiltMapView"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ app:center_latitude="38.90252"
+ app:center_longitude="-77.02291"
+ app:style_url="@string/style_mapbox_streets"
+ app:zoom="11" />
</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
index 6c72333b10..d04996dc95 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
@@ -79,6 +79,12 @@
android:title="@string/action_offline" />
<item
+ android:id="@+id/action_mapboxmap"
+ android:checkable="false"
+ android:icon="@drawable/ic_mapboxmap"
+ android:title="@string/action_mapboxmap" />
+
+ <item
android:id="@+id/action_tilt"
android:checkable="false"
android:icon="@drawable/ic_tilt"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index 0746fb15ff..bd3d6390ee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -4,6 +4,7 @@
<string name="app_name">Mapbox GL</string>
<!-- Test Activities -->
+ <string name="activity_mapboxmap">MapboxMap</string>
<string name="activity_tilt">Map Tilt</string>
<string name="activity_infowindow_adapter">InfoWindow Adapter</string>
<string name="activity_map_fragment_suport">Support Map Fragment Activity</string>
@@ -37,6 +38,7 @@
<string name="action_custom_layer">Custom Layer</string>
<string name="action_debug">Cycle map debug options</string>
<string name="action_point_annotations">Toggle point annotations</string>
+ <string name="action_mapboxmap">MapboxMap</string>
<string name="action_info_window_adapter">InfoWindow Adapter</string>
<string name="action_tilt">Tilt</string>
<string name="action_map_fragment">MapFragment</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
index 52dccff158..589084d17c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
@@ -26,6 +26,13 @@ public class MapboxMapOptionsTest {
}
@Test
+ public void testDebugEnabled() {
+ assertFalse(new MapboxMapOptions().getDebugActive());
+ assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive());
+ assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive());
+ }
+
+ @Test
public void testCompassEnabled() {
assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled());
assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled());
@@ -45,6 +52,44 @@ public class MapboxMapOptionsTest {
}
@Test
+ public void testLogoEnabled() {
+ assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled());
+ assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled());
+ }
+
+ @Test
+ public void testLogoGravity() {
+ assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity());
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
+ assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
+ }
+
+ @Test
+ public void testLogoMargins() {
+ assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 1, 2, 3}).getLogoMargins()));
+ assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 0, 0, 0}).getLogoMargins()));
+ }
+
+ @Test
+ public void testAttributionEnabled() {
+ assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled());
+ assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled());
+ }
+
+ @Test
+ public void testAttributionGravity() {
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity());
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
+ assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
+ }
+
+ @Test
+ public void testAttributionMargins() {
+ assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 1, 2, 3}).getAttributionMargins()));
+ assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 0, 0, 0}).getAttributionMargins()));
+ }
+
+ @Test
public void testMinZoom() {
assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoom());
assertEquals(5.0f, new MapboxMapOptions().minZoom(5.0f).getMinZoom());
@@ -59,31 +104,43 @@ public class MapboxMapOptionsTest {
}
@Test
+ public void testLocationEnabled() {
+ assertFalse(new MapboxMapOptions().getLocationEnabled());
+ assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled());
+ assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled());
+ }
+
+ @Test
public void testTiltGesturesEnabled() {
- assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTitltGesturesEnabeld());
- assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTitltGesturesEnabeld());
+ assertTrue(new MapboxMapOptions().getTiltGesturesEnabled());
+ assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled());
+ assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled());
}
@Test
public void testScrollGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getScrollGesturesEnabled());
assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled());
assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled());
}
@Test
public void testZoomGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getZoomGesturesEnabled());
assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled());
assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled());
}
@Test
public void testRotateGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getRotateGesturesEnabled());
assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled());
assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled());
}
@Test
public void testZoomControlsEnabled() {
+ assertFalse(new MapboxMapOptions().getZoomControlsEnabled());
assertTrue(new MapboxMapOptions().zoomControlsEnabled(true).getZoomControlsEnabled());
assertFalse(new MapboxMapOptions().zoomControlsEnabled(false).getZoomControlsEnabled());
}
@@ -109,6 +166,5 @@ public class MapboxMapOptionsTest {
assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken());
assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle());
}
-
}