From 05cbd4e31d40921acea40ad935ceb06a0ea08324 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 29 Jun 2017 13:36:59 +0200 Subject: [android] - keep state of initial overlain views margins (#9391) --- .../java/com/mapbox/mapboxsdk/maps/UiSettings.java | 45 ++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java index 3f43c23a7f..e71d509fcf 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java @@ -36,8 +36,14 @@ public final class UiSettings { private final FocalPointChangeListener focalPointChangeListener; private final Projection projection; private final CompassView compassView; + private final int[] compassMargins = new int[4]; + private final ImageView attributionsView; + private final int[] attributionsMargins = new int[4]; + private final View logoView; + private final int[] logoMargins = new int[4]; + private float pixelRatio; private boolean rotateGesturesEnabled = true; @@ -368,7 +374,7 @@ public final class UiSettings { */ @UiThread public void setCompassMargins(int left, int top, int right, int bottom) { - setWidgetMargins(compassView, left, top, right, bottom); + setWidgetMargins(compassView, compassMargins, left, top, right, bottom); } /** @@ -377,7 +383,7 @@ public final class UiSettings { * @return The left margin in pixels */ public int getCompassMarginLeft() { - return ((FrameLayout.LayoutParams) compassView.getLayoutParams()).leftMargin; + return compassMargins[0]; } /** @@ -386,7 +392,7 @@ public final class UiSettings { * @return The top margin in pixels */ public int getCompassMarginTop() { - return ((FrameLayout.LayoutParams) compassView.getLayoutParams()).topMargin; + return compassMargins[1]; } /** @@ -395,7 +401,7 @@ public final class UiSettings { * @return The right margin in pixels */ public int getCompassMarginRight() { - return ((FrameLayout.LayoutParams) compassView.getLayoutParams()).rightMargin; + return compassMargins[2]; } /** @@ -404,7 +410,7 @@ public final class UiSettings { * @return The bottom margin in pixels */ public int getCompassMarginBottom() { - return ((FrameLayout.LayoutParams) compassView.getLayoutParams()).bottomMargin; + return compassMargins[3]; } /** @@ -478,7 +484,7 @@ public final class UiSettings { * @param bottom The bottom margin in pixels. */ public void setLogoMargins(int left, int top, int right, int bottom) { - setWidgetMargins(logoView, left, top, right, bottom); + setWidgetMargins(logoView, logoMargins, left, top, right, bottom); } /** @@ -487,7 +493,7 @@ public final class UiSettings { * @return The left margin in pixels */ public int getLogoMarginLeft() { - return ((FrameLayout.LayoutParams) logoView.getLayoutParams()).leftMargin; + return logoMargins[0]; } /** @@ -496,7 +502,7 @@ public final class UiSettings { * @return The top margin in pixels */ public int getLogoMarginTop() { - return ((FrameLayout.LayoutParams) logoView.getLayoutParams()).topMargin; + return logoMargins[1]; } /** @@ -505,7 +511,7 @@ public final class UiSettings { * @return The right margin in pixels */ public int getLogoMarginRight() { - return ((FrameLayout.LayoutParams) logoView.getLayoutParams()).rightMargin; + return logoMargins[2]; } /** @@ -514,7 +520,7 @@ public final class UiSettings { * @return The bottom margin in pixels */ public int getLogoMarginBottom() { - return ((FrameLayout.LayoutParams) logoView.getLayoutParams()).bottomMargin; + return logoMargins[3]; } /** @@ -568,7 +574,7 @@ public final class UiSettings { * @param bottom The bottom margin in pixels. */ public void setAttributionMargins(int left, int top, int right, int bottom) { - setWidgetMargins(attributionsView, left, top, right, bottom); + setWidgetMargins(attributionsView, attributionsMargins, left, top, right, bottom); } /** @@ -595,7 +601,7 @@ public final class UiSettings { * @return The left margin in pixels */ public int getAttributionMarginLeft() { - return ((FrameLayout.LayoutParams) attributionsView.getLayoutParams()).leftMargin; + return attributionsMargins[0]; } /** @@ -604,7 +610,7 @@ public final class UiSettings { * @return The top margin in pixels */ public int getAttributionMarginTop() { - return ((FrameLayout.LayoutParams) attributionsView.getLayoutParams()).topMargin; + return attributionsMargins[1]; } /** @@ -613,7 +619,7 @@ public final class UiSettings { * @return The right margin in pixels */ public int getAttributionMarginRight() { - return ((FrameLayout.LayoutParams) attributionsView.getLayoutParams()).rightMargin; + return attributionsMargins[2]; } /** @@ -622,7 +628,7 @@ public final class UiSettings { * @return The bottom margin in pixels */ public int getAttributionMarginBottom() { - return ((FrameLayout.LayoutParams) attributionsView.getLayoutParams()).bottomMargin; + return attributionsMargins[3]; } /** @@ -926,7 +932,14 @@ public final class UiSettings { view.setLayoutParams(layoutParams); } - private void setWidgetMargins(@NonNull final View view, int left, int top, int right, int bottom) { + private void setWidgetMargins(@NonNull final View view, int[] initMargins, int left, int top, int right, int bottom) { + // keep state of initially set margins + initMargins[0] = left; + initMargins[1] = top; + initMargins[2] = right; + initMargins[3] = bottom; + + // convert inital margins with padding int[] contentPadding = projection.getContentPadding(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); left += contentPadding[0]; -- cgit v1.2.1 From b4cb719ceba57b5b2879d54473531c3404a20c77 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 10 Aug 2017 13:18:46 +0200 Subject: [android] - provide compability with Samsung devices forcing 3-4 array matrix length --- .../mapboxsdk/maps/widgets/MyLocationView.java | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 24da59bb7e..61b0efe656 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -797,6 +797,9 @@ public class MyLocationView extends View { private Sensor rotationVectorSensor; private float[] matrix = new float[9]; + private float[] rotationVectorValue; + private float[] truncatedRotationVectorValue = new float[4]; + private float[] orientation = new float[3]; private boolean reportMissingSensor = true; // Compass data @@ -833,9 +836,8 @@ public class MyLocationView extends View { } if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) { - - // calculate the rotation matrix - SensorManager.getRotationMatrixFromVector(matrix, event.values); + rotationVectorValue = getRotationVectorFromSensorEvent(event); + SensorManager.getRotationMatrixFromVector(matrix, rotationVectorValue); SensorManager.getOrientation(matrix, orientation); magneticHeading = (float) Math.toDegrees(SensorManager.getOrientation(matrix, orientation)[0]); @@ -852,6 +854,28 @@ public class MyLocationView extends View { } } + /** + * Pulls out the rotation vector from a SensorEvent, with a maximum length + * vector of four elements to avoid potential compatibility issues. + * + * @param event the sensor event + * @return the events rotation vector, potentially truncated + */ + @NonNull + float[] getRotationVectorFromSensorEvent(@NonNull SensorEvent event) { + if (event.values.length > 4) { + // On some Samsung devices SensorManager.getRotationMatrixFromVector + // appears to throw an exception if rotation vector has length > 4. + // For the purposes of this class the first 4 values of the + // rotation vector are sufficient (see crbug.com/335298 for details). + // Only affects Android 4.3 + System.arraycopy(event.values, 0, truncatedRotationVectorValue, 0, 4); + return truncatedRotationVectorValue; + } else { + return event.values; + } + } + private void rotateCamera(float rotation) { CameraPosition.Builder builder = new CameraPosition.Builder(); builder.bearing(rotation); -- cgit v1.2.1 From 2802c55bd5e4f104fee991cb944e4d2503cbb18d Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 10 Aug 2017 15:07:48 +0200 Subject: [android] - create smallest possible LatLngBounds when visible region crosses the dateline --- .../com/mapbox/mapboxsdk/geometry/LatLngBounds.java | 10 ++++++++++ .../java/com/mapbox/mapboxsdk/maps/Projection.java | 15 +++++++-------- .../activity/maplayout/SimpleMapActivity.java | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index 505b2db192..8b2ccffef1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -221,6 +221,16 @@ public class LatLngBounds implements Parcelable { return new LatLng[] {getNorthEast(), getSouthWest()}; } + /** + * Constructs a LatLngBounds from doubles representing a LatLng pair. + *

+ * This method doesn't recalculate most east or most west boundaries. + *

+ */ + public static LatLngBounds from(double latNorth, double lonEast, double latSouth, double lonWest) { + return new LatLngBounds(latNorth, lonEast, latSouth, lonWest); + } + /** * Constructs a LatLngBounds from current bounds with an additional latitude-longitude pair. * diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index e0a634521b..3841809a65 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -78,8 +78,6 @@ public class Projection { * @return The projection of the viewing frustum in its current state. */ public VisibleRegion getVisibleRegion() { - LatLngBounds.Builder builder = new LatLngBounds.Builder(); - float left = 0; float right = nativeMapView.getWidth(); float top = 0; @@ -90,12 +88,13 @@ public class Projection { LatLng bottomRight = fromScreenLocation(new PointF(right, bottom)); LatLng bottomLeft = fromScreenLocation(new PointF(left, bottom)); - builder.include(topLeft) - .include(topRight) - .include(bottomRight) - .include(bottomLeft); - - return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight, builder.build()); + return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight, + LatLngBounds.from( + topRight.getLatitude(), + topRight.getLongitude(), + bottomLeft.getLatitude(), + bottomLeft.getLongitude()) + ); } /** diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java index 8f8a5af3cc..badb6718cf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java @@ -1,11 +1,18 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; +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.Projection; import com.mapbox.mapboxsdk.testapp.R; +import timber.log.Timber; + /** * Test activity showcasing a simple MapView without any MapboxMap interaction. */ @@ -20,6 +27,19 @@ public class SimpleMapActivity extends AppCompatActivity { mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap mapboxMap) { + final Projection projection = mapboxMap.getProjection(); + + mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { + @Override + public void onMapClick(@NonNull LatLng point) { + Timber.e(projection.getVisibleRegion().toString()); + } + }); + } + }); } @Override -- cgit v1.2.1 From a83c19e9543ae3a84bfe41db9a03a9f4f4957064 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Mon, 14 Aug 2017 14:18:51 +0200 Subject: [android] - re-add projectedMeters --- .../main/java/com/mapbox/mapboxsdk/maps/Projection.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index 3841809a65..16c73b1ca5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -6,6 +6,7 @@ import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.geometry.ProjectedMeters; import com.mapbox.mapboxsdk.geometry.VisibleRegion; /** @@ -44,6 +45,20 @@ public class Projection { setContentPadding(contentPadding, userLocationViewPadding); } + /** + * Returns the spherical Mercator projected meters for a LatLng. + */ + public ProjectedMeters getProjectedMetersForLatLng(LatLng latLng) { + return nativeMapView.projectedMetersForLatLng(latLng); + } + + /** + * Returns the LatLng for a spherical Mercator projected meters. + */ + public LatLng getLatLngForProjectedMeters(ProjectedMeters projectedMeters) { + return nativeMapView.latLngForProjectedMeters(projectedMeters); + } + /** *

* Returns the distance spanned by one pixel at the specified latitude and current zoom level. -- cgit v1.2.1 From f356ff4b0047179d42e25d46578fc464e341ee5d Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Wed, 16 Aug 2017 10:31:21 +0200 Subject: [android] - enable location change animation of MyLocationView by default --- .../src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 61b0efe656..f74286705c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -75,7 +75,7 @@ public class MyLocationView extends View { private ValueAnimator locationChangeAnimator; private ValueAnimator accuracyAnimator; private ValueAnimator directionAnimator; - private boolean locationChangeAnimationEnabled; + private boolean locationChangeAnimationEnabled = true; private ValueAnimator.AnimatorUpdateListener invalidateSelfOnUpdateListener = new ValueAnimator.AnimatorUpdateListener() { -- cgit v1.2.1 From 341165cef44c7ecd67f3a911eb29e0433d33e14c Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Thu, 17 Aug 2017 10:32:49 +0200 Subject: [android] - avoid IndexOutOfBounds when destroying map object --- .../mapbox/mapboxsdk/maps/AnnotationManager.java | 46 +++++++++------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java index 712ab67de0..d15d5eddf8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java @@ -212,22 +212,19 @@ class AnnotationManager { } if (markers.size() > 0) { - long[] ids = null; + long[] ids; if (nativeMapView != null) { ids = nativeMapView.addMarkers(markers); + } else { + ids = new long[markers.size()]; } - long id = 0; + long id; Marker m; - for (int i = 0; i < markers.size(); i++) { + for (int i = 0; i < ids.length; i++) { m = markers.get(i); m.setMapboxMap(mapboxMap); - if (ids != null) { - id = ids[i]; - } else { - // unit test - id++; - } + id = ids[i]; m.setId(id); annotations.put(id, m); } @@ -481,21 +478,18 @@ class AnnotationManager { } } - long[] ids = null; + long[] ids; if (nativeMapView != null) { ids = nativeMapView.addPolygons(polygons); + } else { + ids = new long[polygons.size()]; } - long id = 0; - for (int i = 0; i < polygons.size(); i++) { + long id; + for (int i = 0; i < ids.length; i++) { polygon = polygons.get(i); polygon.setMapboxMap(mapboxMap); - if (ids != null) { - id = ids[i]; - } else { - // unit test - id++; - } + id = ids[i]; polygon.setId(id); shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); annotations.put(id, polygon); @@ -555,23 +549,19 @@ class AnnotationManager { } } - long[] ids = null; + long[] ids; if (nativeMapView != null) { ids = nativeMapView.addPolylines(polylines); + } else { + ids = new long[polylines.size()]; } - long id = 0; + long id; Polyline p; - - for (int i = 0; i < polylines.size(); i++) { + for (int i = 0; i < ids.length; i++) { p = polylines.get(i); p.setMapboxMap(mapboxMap); - if (ids != null) { - id = ids[i]; - } else { - // unit test - id++; - } + id = ids[i]; p.setId(id); shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); annotations.put(id, p); -- cgit v1.2.1 From 78633322d76f68d552e1059dc069afaf59a132d2 Mon Sep 17 00:00:00 2001 From: Cameron Mace Date: Thu, 17 Aug 2017 17:34:43 -0400 Subject: bumped MAS version number --- platform/android/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/dependencies.gradle b/platform/android/dependencies.gradle index a4b202086a..1257ec59a6 100644 --- a/platform/android/dependencies.gradle +++ b/platform/android/dependencies.gradle @@ -7,7 +7,7 @@ ext { versionCode = 12 versionName = "5.1.3" - mapboxServicesVersion = "2.2.0" + mapboxServicesVersion = "2.2.1" supportLibVersion = "25.3.1" wearableVersion = '2.0.0' espressoVersion = '2.2.2' -- cgit v1.2.1 From 6de3e6fe7001bf8ce6bfff066855e73150377124 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 18 Aug 2017 11:49:00 +0200 Subject: [android] - update changelog for v5.1.3 --- platform/android/CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index 485ceaab8a..6d1422e234 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,7 +2,18 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. -## 5.1.2 - August 2, 20017 +## 5.1.3 - August 18, 2017 + +* Use separate attribute component for line normals [#9753](https://github.com/mapbox/mapbox-gl-native/pull/9753) +* Track state of initial overlain views margins [#9391](https://github.com/mapbox/mapbox-gl-native/pull/9391) +* Compability for Samsung devices forcing 3-4 array vector length [#9746](https://github.com/mapbox/mapbox-gl-native/pull/9746) +* Smallest LatLngBounds when visible region crosses dateline [#9747](https://github.com/mapbox/mapbox-gl-native/pull/9747) +* Readd ProjectMeters [#9766](https://github.com/mapbox/mapbox-gl-native/pull/9766) +* Enable location change animation of MyLocationView by default [#9779](https://github.com/mapbox/mapbox-gl-native/pull/9779) +* Avoid IndexOutOfBoundsException when destroying map object [#9789](https://github.com/mapbox/mapbox-gl-native/pull/9789) +* MAS 2.2.1 [#9796](https://github.com/mapbox/mapbox-gl-native/pull/9796) + +## 5.1.2 - August 2, 2017 * Disable program caching on Ardreno GPU 3xx, 4xx and 5xx [#9625](https://github.com/mapbox/mapbox-gl-native/pull/9625) * GeoJSON proguard issue [#9577](https://github.com/mapbox/mapbox-gl-native/pull/9577) -- cgit v1.2.1 From 8d04e099c7a4b0c8b100c24930f0407ba13b454c Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 18 Aug 2017 11:50:45 +0200 Subject: [android] - update config for next reelease --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- .../resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties | 2 +- platform/android/dependencies.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index af1d04ab97..033903822f 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.1.3-SNAPSHOT +VERSION_NAME=5.1.4-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties index 3cfc7d5fdc..81e0e5d7a8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties +++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk -fabric-version=5.1.2 +fabric-version=5.1.3 fabric-build-type=binary diff --git a/platform/android/dependencies.gradle b/platform/android/dependencies.gradle index 1257ec59a6..4302fd816a 100644 --- a/platform/android/dependencies.gradle +++ b/platform/android/dependencies.gradle @@ -5,7 +5,7 @@ ext { buildToolsVersion = "25.0.2" versionCode = 12 - versionName = "5.1.3" + versionName = "5.1.4" mapboxServicesVersion = "2.2.1" supportLibVersion = "25.3.1" -- cgit v1.2.1 From acb8199d326eda02102b2d409ebec510053fec1b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 18 Aug 2017 15:17:04 -0400 Subject: [ios] Document annotations-as-features limitations w/feature querying Also move visibleAnnotations next to visibleAnnotationsInRect:. --- platform/ios/src/MGLMapView.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index a0aada9a9c..a514d15b41 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -990,16 +990,6 @@ MGL_EXPORT IB_DESIGNABLE */ @property (nonatomic, readonly, nullable) NS_ARRAY_OF(id ) *annotations; -/** - The complete list of annotations associated with the receiver that are - currently visible. - - The objects in this array must adopt the `MGLAnnotation` protocol. If no - annotations are associated with the map view or if no annotations associated - with the map view are currently visible, the value of this property is `nil`. - */ -@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id ) *visibleAnnotations; - /** Adds an annotation to the map view. @@ -1094,6 +1084,16 @@ MGL_EXPORT IB_DESIGNABLE */ - (nullable __kindof MGLAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier; +/** + The complete list of annotations associated with the receiver that are + currently visible. + + The objects in this array must adopt the `MGLAnnotation` protocol. If no + annotations are associated with the map view or if no annotations associated + with the map view are currently visible, the value of this property is `nil`. + */ +@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id ) *visibleAnnotations; + /** Returns the list of annotations associated with the receiver that intersect with the given rectangle. @@ -1254,6 +1254,11 @@ MGL_EXPORT IB_DESIGNABLE `-[MGLVectorSource featuresInSourceLayersWithIdentifiers:predicate:]` and `-[MGLShapeSource featuresMatchingPredicate:]` methods on the relevant sources. + The returned features may also include features corresponding to annotations. + These features are not object-equal to the `MGLAnnotation` objects that were + originally added to the map. To query the map for annotations, use + `visibleAnnotations` or `-[MGLMapView visibleAnnotationsInRect:]`. + @note Layer identifiers are not guaranteed to exist across styles or different versions of the same style. Applications that use this API must first set the style URL to an explicitly versioned style using a convenience method -- cgit v1.2.1 From b2fd7b680c0bdcb5918424487aba9f083149c123 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 23 Aug 2017 16:06:12 -0400 Subject: [ios] Fix heading update loop Updating CLLocationManager.headingOrientation triggers a new heading update, even if there was no actual change in its value. --- platform/ios/CHANGELOG.md | 6 +++++- platform/ios/src/MGLMapView.mm | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e657472aa5..c17a73b059 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,7 +2,11 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 3.6.2 +## 3.6.3 + +* Fixed an issue where user heading tracking mode would update too frequently. ([#9845](https://github.com/mapbox/mapbox-gl-native/pull/9845)) + +## 3.6.2 - August 18, 2017 * Added an `MGLStyle.localizesLabels` property, off by default, that localizes any Mapbox Streets–sourced symbol layer into the user’s preferred language. ([#9582](https://github.com/mapbox/mapbox-gl-native/pull/9582)) * Added an additional camera method to MGLMapView that accepts an edge padding parameter. ([#9651](https://github.com/mapbox/mapbox-gl-native/pull/9651)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 715c32186d..18a8d2608a 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4690,30 +4690,39 @@ public: { // note that right/left device and interface orientations are opposites (see UIApplication.h) // + CLDeviceOrientation orientation; switch ([[UIApplication sharedApplication] statusBarOrientation]) { case (UIInterfaceOrientationLandscapeLeft): { - self.locationManager.headingOrientation = CLDeviceOrientationLandscapeRight; + orientation = CLDeviceOrientationLandscapeRight; break; } case (UIInterfaceOrientationLandscapeRight): { - self.locationManager.headingOrientation = CLDeviceOrientationLandscapeLeft; + orientation = CLDeviceOrientationLandscapeLeft; break; } case (UIInterfaceOrientationPortraitUpsideDown): { - self.locationManager.headingOrientation = CLDeviceOrientationPortraitUpsideDown; + orientation = CLDeviceOrientationPortraitUpsideDown; break; } case (UIInterfaceOrientationPortrait): default: { - self.locationManager.headingOrientation = CLDeviceOrientationPortrait; + orientation = CLDeviceOrientationPortrait; break; } } + + // Setting the location manager's heading orientation causes it to send + // a heading event, which in turn makes us redraw, which kicks off a + // loop... so don't do that. rdar://34059173 + if (self.locationManager.headingOrientation != orientation) + { + self.locationManager.headingOrientation = orientation; + } } } -- cgit v1.2.1 From fb07beebb4d7284047ecba1af31b82b22be5e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 10 Jul 2017 13:48:43 +0200 Subject: [build] Don't use maybe-uninitialized and misleading-indentation in Clang, since they're not implemented there Cherry-pick of d03fd0dce2efc101021b4cf351945680afaa4349. --- src/mbgl/annotation/symbol_annotation_impl.hpp | 3 +++ src/mbgl/text/collision_tile.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp index c9a99ffb8d..2c263ab41e 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.hpp +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -17,7 +17,10 @@ #pragma GCC diagnostic ignored "-Wdeprecated-register" #pragma GCC diagnostic ignored "-Wshorten-64-to-32" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#ifndef __clang__ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif #include #include #include diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index ea4324edaf..4508e13a4b 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -16,7 +16,10 @@ #pragma GCC diagnostic ignored "-Wdeprecated-register" #pragma GCC diagnostic ignored "-Wshorten-64-to-32" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#ifndef __clang__ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif #include #include #include -- cgit v1.2.1 From 1f5a0ec48bc9853674e00ada341af3a352aa02ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 11 Jul 2017 11:33:51 +0200 Subject: [build] Don't fail hard for unknown warning groups --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8144d880ce..7ac2ea7e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,10 @@ if(APPLE) endif() set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") -if(CMAKE_COMPILER_IS_GNUCXX) + +if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unknown-warning-option") +elseif(CMAKE_COMPILER_IS_GNUCXX) # https://svn.boost.org/trac/boost/ticket/9240 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") endif() -- cgit v1.2.1 From 5cad92cc336768a93875865c6d4abbfe10c13bd1 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 25 Aug 2017 16:12:00 -0400 Subject: [ios] Print Xcode and SDK version during packaging --- platform/ios/scripts/package.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/ios/scripts/package.sh b/platform/ios/scripts/package.sh index a5e2f87e20..3a7342034a 100755 --- a/platform/ios/scripts/package.sh +++ b/platform/ios/scripts/package.sh @@ -31,7 +31,9 @@ function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } trap finish EXIT -step "Configuring ${FORMAT:-dynamic and static} ${BUILDTYPE} framework for ${SDK}; symbols: ${SYMBOLS}" +step "Configuring ${FORMAT:-dynamic and static} ${BUILDTYPE} framework for ${SDK} ${IOS_SDK_VERSION}; symbols: ${SYMBOLS}" + +xcodebuild -version rm -rf ${OUTPUT} if [[ ${BUILD_STATIC} == true ]]; then -- cgit v1.2.1 From a7f06366d2c431bdf34fcfa14314be43ac09987b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 25 Aug 2017 18:06:39 -0400 Subject: [ios] Support iOS 11 location usage descriptions --- platform/ios/CHANGELOG.md | 1 + platform/ios/app/Info.plist | 6 ++++-- platform/ios/src/MGLMapView.mm | 26 +++++++++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index c17a73b059..d8267092df 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## 3.6.3 * Fixed an issue where user heading tracking mode would update too frequently. ([#9845](https://github.com/mapbox/mapbox-gl-native/pull/9845)) +* Added support for iOS 11 location usage descriptions. ([#9869](https://github.com/mapbox/mapbox-gl-native/pull/9869)) ## 3.6.2 - August 18, 2017 diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist index 167e66fa09..a98a8c10c5 100644 --- a/platform/ios/app/Info.plist +++ b/platform/ios/app/Info.plist @@ -27,9 +27,11 @@ NSHumanReadableCopyright © 2014–2017 Mapbox NSLocationAlwaysUsageDescription - The map will ALWAYS display the user’s location. + The map will display your location. The map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. NSLocationWhenInUseUsageDescription - The map will display the user’s location. + The map will display your location. + NSLocationAlwaysAndWhenInUseUsageDescription + The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 18a8d2608a..af7122fc14 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4160,23 +4160,35 @@ public: { self.locationManager = [[CLLocationManager alloc] init]; - if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) + if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { - BOOL hasLocationDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] || [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]; - if (!hasLocationDescription) + BOOL requiresWhenInUseUsageDescription = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){11,0,0}]; + BOOL hasWhenInUseUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]; + BOOL hasAlwaysUsageDescription; + if (requiresWhenInUseUsageDescription) { - [NSException raise:@"Missing Location Services usage description" format: - @"This app must have a value for NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription in its Info.plist."]; + hasAlwaysUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"] && hasWhenInUseUsageDescription; + } + else + { + hasAlwaysUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]; } - if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) + if (hasAlwaysUsageDescription) { [self.locationManager requestAlwaysAuthorization]; } - else if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) + else if (hasWhenInUseUsageDescription) { [self.locationManager requestWhenInUseAuthorization]; } + else + { + NSString *suggestedUsageKeys = requiresWhenInUseUsageDescription ? + @"NSLocationWhenInUseUsageDescription and (optionally) NSLocationAlwaysAndWhenInUseUsageDescription" : + @"NSLocationWhenInUseUsageDescription and/or NSLocationAlwaysUsageDescription"; + [NSException raise:@"Missing Location Services usage description" format:@"This app must have a value for %@ in its Info.plist.", suggestedUsageKeys]; + } } self.locationManager.headingFilter = 5.0; -- cgit v1.2.1 From e78620c70567a995a6f02ae3ee85cc5dd7f3fade Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 27 Jul 2017 22:28:41 -0400 Subject: [ios] Set location to nil until the user's location is determined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation for the `location` property states that "This property contains `nil` if the map view is not currently showing the user location or if the user’s location has not yet been determined." The iOS SDK presently returns a garbage value, which has some rather annoying consequences when the value should logically be nullable. This change should rectify the issue. With _location no longer initialized to an invalid coordinate, trying to access `_location.coordinate` when `_location == nil` will return `0, 0`, which is a valid coordinate. --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLUserLocation.h | 3 +-- platform/ios/src/MGLUserLocation.m | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index d8267092df..a1d8808033 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed an issue where user heading tracking mode would update too frequently. ([#9845](https://github.com/mapbox/mapbox-gl-native/pull/9845)) * Added support for iOS 11 location usage descriptions. ([#9869](https://github.com/mapbox/mapbox-gl-native/pull/9869)) +* Fixed an issue where `MGLUserLocation.location` did not follow its documented initialization behavior. This property will now properly return `nil` until the user’s location has been determined. ([#9639](https://github.com/mapbox/mapbox-gl-native/pull/9639)) ## 3.6.2 - August 18, 2017 diff --git a/platform/ios/src/MGLUserLocation.h b/platform/ios/src/MGLUserLocation.h index 8c6fe46136..91abadbcb7 100644 --- a/platform/ios/src/MGLUserLocation.h +++ b/platform/ios/src/MGLUserLocation.h @@ -20,8 +20,7 @@ MGL_EXPORT /** The current location of the device. (read-only) - This property contains `nil` if the map view is not currently showing the user - location or if the user’s location has not yet been determined. + This property returns `nil` if the user’s location has not yet been determined. */ @property (nonatomic, readonly, nullable) CLLocation *location; diff --git a/platform/ios/src/MGLUserLocation.m b/platform/ios/src/MGLUserLocation.m index 1c9649c09e..074d138a72 100644 --- a/platform/ios/src/MGLUserLocation.m +++ b/platform/ios/src/MGLUserLocation.m @@ -19,7 +19,6 @@ NS_ASSUME_NONNULL_END { if (self = [super init]) { - _location = [[CLLocation alloc] initWithLatitude:MAXFLOAT longitude:MAXFLOAT]; _mapView = mapView; } @@ -102,7 +101,7 @@ NS_ASSUME_NONNULL_END - (CLLocationCoordinate2D)coordinate { - return self.location.coordinate; + return _location ? _location.coordinate : kCLLocationCoordinate2DInvalid; } - (NSString *)title -- cgit v1.2.1 From 9c4071fe8684e320d398a2f8bdcfbdffdd64ec68 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 21 Aug 2017 17:58:27 +0300 Subject: [core] Remove database on schema downgrade Previously we were throwing an exception. --- platform/default/mbgl/storage/offline_database.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp index 02736f10a4..204ee04c92 100644 --- a/platform/default/mbgl/storage/offline_database.cpp +++ b/platform/default/mbgl/storage/offline_database.cpp @@ -50,7 +50,7 @@ void OfflineDatabase::ensureSchema() { case 3: // no-op and fall through case 4: migrateToVersion5(); // fall through case 5: return; - default: throw std::runtime_error("unknown schema version"); + default: break; // downgrade, delete the database } removeExisting(); -- cgit v1.2.1 From 2640109887655b3aa0cb1a2d06ddb093282d03b7 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 21 Aug 2017 17:58:36 +0300 Subject: [tests] Enforce the schema downgrade behavior Which is, delete and recreate the database. --- test/fixtures/offline_database/v999.db | Bin 0 -> 19456 bytes test/storage/offline_database.test.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/fixtures/offline_database/v999.db diff --git a/test/fixtures/offline_database/v999.db b/test/fixtures/offline_database/v999.db new file mode 100644 index 0000000000..97c36cce36 Binary files /dev/null and b/test/fixtures/offline_database/v999.db differ diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp index 872310e46f..243d0dc43c 100644 --- a/test/storage/offline_database.test.cpp +++ b/test/storage/offline_database.test.cpp @@ -698,3 +698,27 @@ TEST(OfflineDatabase, MigrateFromV4Schema) { // Synchronous setting should be FULL (2) after migration to v5. EXPECT_EQ(2, databaseSyncMode("test/fixtures/offline_database/v5.db")); } + +TEST(OfflineDatabase, DowngradeSchema) { + using namespace mbgl; + + // v999.db is a v999 database, it should be deleted + // and recreated with the current schema. + + deleteFile("test/fixtures/offline_database/migrated.db"); + writeFile("test/fixtures/offline_database/migrated.db", util::read_file("test/fixtures/offline_database/v999.db")); + + { + OfflineDatabase db("test/fixtures/offline_database/migrated.db", 0); + } + + EXPECT_EQ(5, databaseUserVersion("test/fixtures/offline_database/migrated.db")); + + EXPECT_EQ((std::vector{ "id", "url_template", "pixel_ratio", "z", "x", "y", + "expires", "modified", "etag", "data", "compressed", + "accessed" }), + databaseTableColumns("test/fixtures/offline_database/migrated.db", "tiles")); + EXPECT_EQ((std::vector{ "id", "url", "kind", "expires", "modified", "etag", "data", + "compressed", "accessed" }), + databaseTableColumns("test/fixtures/offline_database/migrated.db", "resources")); +} -- cgit v1.2.1 From eedd90961168037954e534507f632fac7cb0a8ae Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 22 Aug 2017 16:13:07 -0400 Subject: [tests] Cherry-pick OfflineDatabase::databaseTableColumns Originally part of the much larger f0a7c45064c3ce3f509b1c2035fcaa07ccc35a99 --- test/storage/offline_database.test.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp index 243d0dc43c..fbf515679e 100644 --- a/test/storage/offline_database.test.cpp +++ b/test/storage/offline_database.test.cpp @@ -634,6 +634,17 @@ static int databaseSyncMode(const std::string& path) { return stmt.get(0); } +static std::vector databaseTableColumns(const std::string& path, const std::string& name) { + mapbox::sqlite::Database db(path, mapbox::sqlite::ReadOnly); + const auto sql = std::string("pragma table_info(") + name + ")"; + mapbox::sqlite::Statement stmt = db.prepare(sql.c_str()); + std::vector columns; + while (stmt.run()) { + columns.push_back(stmt.get(1)); + } + return columns; +} + TEST(OfflineDatabase, MigrateFromV2Schema) { using namespace mbgl; -- cgit v1.2.1 From c8dc77f06fa58112797bf1ae21fe8578512dc317 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Wed, 30 Aug 2017 16:25:57 -0400 Subject: [ios, macos] Make minimumZoomLevel and maximumZoomLevel IBInspectable. (#9729) * [ios, macos] Make minimumZoomLevel and maximumZoomLevel IBInspectable. * [ios, macos] Update changelogs. --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.h | 4 ++-- platform/macos/CHANGELOG.md | 1 + platform/macos/src/MGLMapView.h | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index a1d8808033..1fe6f35953 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed an issue where user heading tracking mode would update too frequently. ([#9845](https://github.com/mapbox/mapbox-gl-native/pull/9845)) * Added support for iOS 11 location usage descriptions. ([#9869](https://github.com/mapbox/mapbox-gl-native/pull/9869)) * Fixed an issue where `MGLUserLocation.location` did not follow its documented initialization behavior. This property will now properly return `nil` until the user’s location has been determined. ([#9639](https://github.com/mapbox/mapbox-gl-native/pull/9639)) +* `MGLMapView`’s `minimumZoomLevel` and `maximumZoomLevel` properties are now available in Interface Builder’s Attributes inspector. ([#9729](https://github.com/mapbox/mapbox-gl-native/pull/9729)) ## 3.6.2 - August 18, 2017 diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index a514d15b41..b475a21d2b 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -577,7 +577,7 @@ MGL_EXPORT IB_DESIGNABLE * * The default minimumZoomLevel is 0. */ -@property (nonatomic) double minimumZoomLevel; +@property (nonatomic) IBInspectable double minimumZoomLevel; /** * The maximum zoom level the map can be shown at. @@ -587,7 +587,7 @@ MGL_EXPORT IB_DESIGNABLE * * The default maximumZoomLevel is 20. */ -@property (nonatomic) double maximumZoomLevel; +@property (nonatomic) IBInspectable double maximumZoomLevel; /** The heading of the map, measured in degrees clockwise from true north. diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index b8ed40cde6..6d31c79259 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -6,6 +6,7 @@ This version of the Mapbox macOS SDK corresponds to version 3.6.2 of the Mapbox * Added an `MGLStyle.localizesLabels` property, off by default, that localizes any Mapbox Streets–sourced symbol layer into the user’s preferred language. ([#9582](https://github.com/mapbox/mapbox-gl-native/pull/9582)) * Fixed an issue that caused `-[MGLShapeSource featuresMatchingPredicate:]` and `-[MGLVectorSource featuresInSourceLayersWithIdentifiers:predicate:]` to always return an empty array. ([#9784](https://github.com/mapbox/mapbox-gl-native/pull/9784)) +* `MGLMapView`’s `minimumZoomLevel` and `maximumZoomLevel` properties are now available in Interface Builder’s Attributes inspector. ([#9729](https://github.com/mapbox/mapbox-gl-native/pull/9729)) ## 0.5.0 diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index fb715a506d..06fd0a67ea 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -239,7 +239,7 @@ MGL_EXPORT IB_DESIGNABLE The default value of this property is 0. */ -@property (nonatomic) double minimumZoomLevel; +@property (nonatomic) IBInspectable double minimumZoomLevel; /** The maximum zoom level the map can be shown at. @@ -249,7 +249,7 @@ MGL_EXPORT IB_DESIGNABLE The default value of this property is 20. */ -@property (nonatomic) double maximumZoomLevel; +@property (nonatomic) IBInspectable double maximumZoomLevel; /** Changes the zoom level of the map and optionally animates the change. -- cgit v1.2.1 From 87348234d16915176fab313f0d3f2dae246216d9 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 30 Aug 2017 12:34:21 -0400 Subject: [ios] Guard against nil user location when setting tracking mode --- platform/ios/src/MGLMapView.mm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index af7122fc14..320c4bcda8 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4338,12 +4338,6 @@ public: [self.locationManager stopUpdatingHeading]; - CLLocation *location = self.userLocation.location; - if (location && self.userLocationAnnotationView) - { - [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; - } - break; } case MGLUserTrackingModeFollowWithHeading: @@ -4360,11 +4354,6 @@ public: [self setZoomLevel:self.currentMinimumZoom animated:YES]; } - if (self.userLocationAnnotationView) - { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; - } - [self updateHeadingForDeviceOrientation]; [self.locationManager startUpdatingHeading]; @@ -4373,6 +4362,15 @@ public: } } + if (_userTrackingMode != MGLUserTrackingModeNone) + { + CLLocation *location = self.userLocation.location; + if (location && self.userLocationAnnotationView) + { + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; + } + } + if ([self.delegate respondsToSelector:@selector(mapView:didChangeUserTrackingMode:animated:)]) { [self.delegate mapView:self didChangeUserTrackingMode:_userTrackingMode animated:animated]; @@ -4411,9 +4409,11 @@ public: if (self.userTrackingMode == MGLUserTrackingModeFollowWithCourse) { self.userTrackingState = MGLUserTrackingStatePossible; - if (self.userLocation.location) + + CLLocation *location = self.userLocation.location; + if (location) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; } } } -- cgit v1.2.1 From cb7eb5cafb18ed24d01a9d091b68ed4f0584966b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 13 Jun 2017 22:37:56 -0400 Subject: [ios] Improve iosapp's zoom debug label --- platform/ios/app/MBXViewController.m | 36 +++++++++++++++++++++++++----------- platform/ios/app/Main.storyboard | 34 +++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 992b7d587a..40e5889526 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -112,7 +112,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @property (nonatomic) IBOutlet MGLMapView *mapView; -@property (weak, nonatomic) IBOutlet UILabel *hudLabel; +@property (weak, nonatomic) IBOutlet UIButton *hudLabel; @property (nonatomic) NSInteger styleIndex; @property (nonatomic) BOOL debugLoggingEnabled; @property (nonatomic) BOOL customUserLocationAnnnotationEnabled; @@ -161,6 +161,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.debugLoggingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"MGLMapboxMetricsDebugLoggingEnabled"]; self.mapView.scaleBar.hidden = NO; self.hudLabel.hidden = YES; + self.hudLabel.titleLabel.font = [UIFont monospacedDigitSystemFontOfSize:10 weight:UIFontWeightRegular]; if ([MGLAccountManager accessToken].length) { @@ -350,7 +351,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [settingsTitles addObjectsFromArray:@[ [NSString stringWithFormat:@"%@ Reuse Queue Stats", (_reuseQueueStatsEnabled ? @"Hide" :@"Show")], @"Start World Tour", - [NSString stringWithFormat:@"%@ Zoom Level", (_showZoomLevelEnabled ? @"Hide" :@"Show")], + [NSString stringWithFormat:@"%@ Zoom/Pitch/Direction Label", (_showZoomLevelEnabled ? @"Hide" :@"Show")], @"Embedded Map View", [NSString stringWithFormat:@"%@ Second Map", ([self.view viewWithTag:2] == nil ? @"Show" : @"Hide")], [NSString stringWithFormat:@"Show Labels in %@", (_usingLocaleBasedCountryLabels ? @"Default Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])], @@ -538,6 +539,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.reuseQueueStatsEnabled = !self.reuseQueueStatsEnabled; self.hudLabel.hidden = !self.reuseQueueStatsEnabled; self.showZoomLevelEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousShowZoomLevel: @@ -545,6 +547,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.showZoomLevelEnabled = !self.showZoomLevelEnabled; self.hudLabel.hidden = !self.showZoomLevelEnabled; self.reuseQueueStatsEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousScrollView: @@ -1791,22 +1794,33 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)mapViewRegionIsChanging:(MGLMapView *)mapView { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation { + [self updateHUD]; +} + +- (void)updateHUD { + if (!self.reuseQueueStatsEnabled && !self.showZoomLevelEnabled) return; + + NSString *hudString; + if (self.reuseQueueStatsEnabled) { NSUInteger queuedAnnotations = 0; - for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) - { + for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) { queuedAnnotations += queue.count; } - self.hudLabel.text = [NSString stringWithFormat:@" Visible: %ld Queued: %ld", (unsigned long)mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; + hudString = [NSString stringWithFormat:@"Visible: %ld Queued: %ld", (unsigned long)self.mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; } else if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; + hudString = [NSString stringWithFormat:@"%.2f ∕ ↕\U0000FE0E%.f° ∕ %.f°", self.mapView.zoomLevel, self.mapView.camera.pitch, self.mapView.direction]; } -} -- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { - if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; - } + [self.hudLabel setTitle:hudString forState:UIControlStateNormal]; } @end diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard index 40198146ab..4bbefd7d22 100644 --- a/platform/ios/app/Main.storyboard +++ b/platform/ios/app/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -33,17 +33,24 @@ -