diff --git a/CHANGELOG.md b/CHANGELOG.md
index 789c44ad..eb12a467 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,30 @@
+## 0.12.0, Oct 5, 2021
+* Update to Maplibre-Android-SDK 9.4.2
+* Update to MapLibre-iOS-SDK 5.12.0
+
+### Changes cherry-picked/ported from tobrun/flutter-mapbox-gl:0.12.0
+* Batch creation/removal for circles, fills and lines [#576](https://github.com/tobrun/flutter-mapbox-gl/pull/576)
+* Dependencies: updated image package [#598](https://github.com/tobrun/flutter-mapbox-gl/pull/598)
+* Improve description to enable location features [#596](https://github.com/tobrun/flutter-mapbox-gl/pull/596)
+* Fix feature manager on release build [#593](https://github.com/tobrun/flutter-mapbox-gl/pull/593)
+* Emit onTap only for the feature above the others [#589](https://github.com/tobrun/flutter-mapbox-gl/pull/589)
+* Add annotationOrder to web [#588](https://github.com/tobrun/flutter-mapbox-gl/pull/588)
+
## Below is the original changelog of the tobrun/flutter-mapbox-gl project, before the fork.
+## 0.11.0, March 30, 2020
+* Fixed issues caused by new android API [#544](https://github.com/tobrun/flutter-mapbox-gl/pull/544)
+* Add option to set maximum offline tile count [#549](https://github.com/tobrun/flutter-mapbox-gl/pull/549)
+* Fixed web build failure due to http package upgrade [#550](https://github.com/tobrun/flutter-mapbox-gl/pull/550)
+* Update OfflineRegion/OfflineRegionDefinition interfaces, synchronize with iOS and Android [#545](https://github.com/tobrun/flutter-mapbox-gl/pull/545)
+* Fix Mapbox GL JS CSS embedding on web [#551](https://github.com/tobrun/flutter-mapbox-gl/pull/551)
+* Update Podfile to fix iOS CI [#565](https://github.com/tobrun/flutter-mapbox-gl/pull/565)
+* Update deprecated patterns to fix CI static analysis [#568](https://github.com/tobrun/flutter-mapbox-gl/pull/568)
+* Add setOffline method on Android [#537](https://github.com/tobrun/flutter-mapbox-gl/pull/537)
+* Add batch mode of screen locations [#554](https://github.com/tobrun/flutter-mapbox-gl/pull/554)
+* Define which annotations consume the tap events [#575](https://github.com/tobrun/flutter-mapbox-gl/pull/575)
+* Remove failed offline region downloads [#583](https://github.com/tobrun/flutter-mapbox-gl/pull/583)
+
## 0.10.0, February 12, 2020
* Merge offline regions [#532](https://github.com/tobrun/flutter-mapbox-gl/pull/532)
* Update offline region metadata [#530](https://github.com/tobrun/flutter-mapbox-gl/pull/530)
diff --git a/README.md b/README.md
index ad765f2f..9fc99980 100644
--- a/README.md
+++ b/README.md
@@ -65,17 +65,25 @@ Map styles can be supplied by setting the `styleString` in the `MapOptions`. The
## Location features
-#### To enable location features in an **Android** application:
+### Android
+Add the `ACCESS_COARSE_LOCATION` or `ACCESS_FINE_LOCATION` permission in the application manifest `android/app/src/main/AndroidManifest.xml` to enable location features in an **Android** application:
+```
+
+
+```
-You need to declare the `ACCESS_COARSE_LOCATION` or `ACCESS_FINE_LOCATION` permission in the AndroidManifest.xml and starting from Android API level 23 also request it at runtime. The plugin does not handle this for you. The example app uses the flutter ['location' plugin](https://pub.dev/packages/location) for this.
+Starting from Android API level 23 you also need to request it at runtime. This plugin does not handle this for you. The example app uses the flutter ['location' plugin](https://pub.dev/packages/location) for this.
-#### To enable location features in an **iOS** application:
+### iOS
+To enable location features in an **iOS** application:
-If you access your users' location, you should also add the following key to your Info.plist to explain why you need access to their location data:
+If you access your users' location, you should also add the following key to `ios/Runner/Info.plist` to explain why you need access to their location data:
-```xml
-NSLocationWhenInUseUsageDescription
-[Your explanation here]
+```
+xml ...
+ NSLocationWhenInUseUsageDescription
+ [Your explanation here]
```
A possible explanation could be: "Shows your location on the map".
diff --git a/android/build.gradle b/android/build.gradle
index a3cba094..d68302c7 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -17,9 +17,6 @@ rootProject.allprojects {
google()
jcenter()
mavenCentral()
- maven {
- url = "https://dl.bintray.com/maplibre/maplibre-gl-native"
- }
}
}
@@ -40,17 +37,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
- implementation 'org.maplibre.gl:android-sdk:9.2.1'
- //implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0"
- implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0") {
- exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
- }
- implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0") {
- exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
- }
- implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-offline-v9:0.7.0") {
- exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
- }
+ implementation 'org.maplibre.gl:android-sdk:9.4.2'
+ implementation 'org.maplibre.gl:android-plugin-annotation-v9:1.0.0'
+ implementation 'org.maplibre.gl:android-plugin-localization-v9:1.0.0'
+ implementation 'org.maplibre.gl:android-plugin-offline-v9:1.0.0'
}
compileOptions {
sourceCompatibility 1.8
diff --git a/android/src/main/java/com/mapbox/mapboxgl/CircleBuilder.java b/android/src/main/java/com/mapbox/mapboxgl/CircleBuilder.java
index 9d902d50..db7accf5 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/CircleBuilder.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/CircleBuilder.java
@@ -21,6 +21,10 @@ class CircleBuilder implements CircleOptionsSink {
this.circleOptions = new CircleOptions();
}
+ public CircleOptions getCircleOptions(){
+ return this.circleOptions;
+ }
+
Circle build() {
return circleManager.create(circleOptions);
}
diff --git a/android/src/main/java/com/mapbox/mapboxgl/CircleController.java b/android/src/main/java/com/mapbox/mapboxgl/CircleController.java
index 404d37b8..76860ea6 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/CircleController.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/CircleController.java
@@ -24,6 +24,10 @@ class CircleController implements CircleOptionsSink {
this.onTappedListener = onTappedListener;
}
+ public Circle getCircle(){
+ return this.circle;
+ }
+
boolean onTap() {
if (onTappedListener != null) {
onTappedListener.onCircleTapped(circle);
diff --git a/android/src/main/java/com/mapbox/mapboxgl/Convert.java b/android/src/main/java/com/mapbox/mapboxgl/Convert.java
index 9ac55862..ca22c4b5 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/Convert.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/Convert.java
@@ -72,6 +72,10 @@ static List toAnnotationOrder(Object o) {
return annotations;
}
+ static List toAnnotationConsumeTapEvents(Object o) {
+ return toAnnotationOrder(o);
+ }
+
static boolean isScrollByCameraUpdate(Object o) {
return toString(toList(o).get(0)).equals("scrollBy");
}
diff --git a/android/src/main/java/com/mapbox/mapboxgl/FillBuilder.java b/android/src/main/java/com/mapbox/mapboxgl/FillBuilder.java
index 09adcd90..b70589cb 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/FillBuilder.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/FillBuilder.java
@@ -22,6 +22,10 @@ class FillBuilder implements FillOptionsSink {
this.fillOptions = new FillOptions();
}
+ public FillOptions getFillOptions(){
+ return this.fillOptions;
+ }
+
Fill build() {
return fillManager.create(fillOptions);
}
diff --git a/android/src/main/java/com/mapbox/mapboxgl/FillController.java b/android/src/main/java/com/mapbox/mapboxgl/FillController.java
index 200b13f7..86bc0113 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/FillController.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/FillController.java
@@ -27,6 +27,10 @@ class FillController implements FillOptionsSink {
this.onTappedListener = onTappedListener;
}
+ public Fill getFill(){
+ return this.fill;
+ }
+
boolean onTap() {
if (onTappedListener != null) {
onTappedListener.onFillTapped(fill);
diff --git a/android/src/main/java/com/mapbox/mapboxgl/GlobalMethodHandler.java b/android/src/main/java/com/mapbox/mapboxgl/GlobalMethodHandler.java
index 4906e64f..1b95f47f 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/GlobalMethodHandler.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/GlobalMethodHandler.java
@@ -5,7 +5,7 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-import android.content.Context;
+import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -64,14 +64,17 @@ public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
installOfflineMapTiles(tilesDb);
result.success(null);
break;
+ case "setOffline":
+ boolean offline = methodCall.argument("offline");
+ ConnectivityReceiver.instance(context).setConnected(offline ? false : null);
+ result.success(null);
+ break;
case "mergeOfflineRegions":
OfflineManagerUtils.mergeRegions(result, context, methodCall.argument("path"));
break;
-
case "setOfflineTileCountLimit":
OfflineManagerUtils.setOfflineTileCountLimit(result, context, methodCall.argument("limit").longValue());
break;
-
case "downloadOfflineRegion":
// Get args from caller
Map definitionMap = (Map) methodCall.argument("definition");
diff --git a/android/src/main/java/com/mapbox/mapboxgl/LineBuilder.java b/android/src/main/java/com/mapbox/mapboxgl/LineBuilder.java
index a164ac60..5d727614 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/LineBuilder.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/LineBuilder.java
@@ -22,6 +22,10 @@ class LineBuilder implements LineOptionsSink {
this.lineOptions = new LineOptions();
}
+ public LineOptions getLineOptions(){
+ return this.lineOptions;
+ }
+
Line build() {
return lineManager.create(lineOptions);
}
diff --git a/android/src/main/java/com/mapbox/mapboxgl/LineController.java b/android/src/main/java/com/mapbox/mapboxgl/LineController.java
index 815401a5..d7715909 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/LineController.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/LineController.java
@@ -32,6 +32,10 @@ class LineController implements LineOptionsSink {
this.onTappedListener = onTappedListener;
}
+ public Line getLine(){
+ return this.line;
+ }
+
boolean onTap() {
if (onTappedListener != null) {
onTappedListener.onLineTapped(line);
diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java
index 7cafa105..045bb76f 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java
@@ -32,11 +32,13 @@ class MapboxMapBuilder implements MapboxMapOptionsSink {
private int myLocationRenderMode = 0;
private String styleString = Style.MAPBOX_STREETS;
private List annotationOrder = new ArrayList();
+ private List annotationConsumeTapEvents = new ArrayList();
+
MapboxMapController build(
int id, Context context, BinaryMessenger messenger, MapboxMapsPlugin.LifecycleProvider lifecycleProvider, String accessToken) {
final MapboxMapController controller =
- new MapboxMapController(id, context, messenger, lifecycleProvider, options, accessToken, styleString, annotationOrder);
+ new MapboxMapController(id, context, messenger, lifecycleProvider, options, accessToken, styleString, annotationOrder, annotationConsumeTapEvents);
controller.init();
controller.setMyLocationEnabled(myLocationEnabled);
controller.setMyLocationTrackingMode(myLocationTrackingMode);
@@ -178,4 +180,9 @@ public void setAttributionButtonMargins(int x, int y) {
public void setAnnotationOrder(List annotations) {
this.annotationOrder = annotations;
}
+
+ public void setAnnotationConsumeTapEvents(List annotations) {
+ this.annotationConsumeTapEvents = annotations;
+ }
+
}
diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
index ba5cfb0d..7ae9c3ee 100644
--- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
+++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
@@ -15,7 +15,6 @@
import android.graphics.RectF;
import android.location.Location;
import android.os.Build;
-import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
@@ -29,11 +28,6 @@
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
-import com.mapbox.android.core.location.LocationEngine;
-import com.mapbox.android.core.location.LocationEngineCallback;
-import com.mapbox.android.core.location.LocationEngineProvider;
-import com.mapbox.android.core.location.LocationEngineResult;
-import com.mapbox.android.telemetry.TelemetryEnabler;
import com.mapbox.geojson.Feature;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -45,6 +39,10 @@
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.location.LocationComponentOptions;
import com.mapbox.mapboxsdk.location.OnCameraTrackingChangedListener;
+import com.mapbox.mapboxsdk.location.engine.LocationEngine;
+import com.mapbox.mapboxsdk.location.engine.LocationEngineCallback;
+import com.mapbox.mapboxsdk.location.engine.LocationEngineProvider;
+import com.mapbox.mapboxsdk.location.engine.LocationEngineResult;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.MapView;
@@ -56,10 +54,13 @@
import com.mapbox.mapboxsdk.plugins.annotation.Annotation;
import com.mapbox.mapboxsdk.plugins.annotation.Circle;
import com.mapbox.mapboxsdk.plugins.annotation.CircleManager;
+import com.mapbox.mapboxsdk.plugins.annotation.CircleOptions;
import com.mapbox.mapboxsdk.plugins.annotation.Fill;
import com.mapbox.mapboxsdk.plugins.annotation.FillManager;
+import com.mapbox.mapboxsdk.plugins.annotation.FillOptions;
import com.mapbox.mapboxsdk.plugins.annotation.Line;
import com.mapbox.mapboxsdk.plugins.annotation.LineManager;
+import com.mapbox.mapboxsdk.plugins.annotation.LineOptions;
import com.mapbox.mapboxsdk.plugins.annotation.OnAnnotationClickListener;
import com.mapbox.mapboxsdk.plugins.annotation.Symbol;
import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager;
@@ -71,10 +72,11 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
@@ -130,7 +132,8 @@ final class MapboxMapController
private LocationEngineCallback locationEngineCallback = null;
private LocalizationPlugin localizationPlugin;
private Style style;
- private List annotationOrder = new ArrayList();
+ private List annotationOrder;
+ private List annotationConsumeTapEvents;
MapboxMapController(
int id,
@@ -140,7 +143,8 @@ final class MapboxMapController
MapboxMapOptions options,
String accessToken,
String styleStringInitial,
- List annotationOrder) {
+ List annotationOrder,
+ List annotationConsumeTapEvents) {
MapBoxUtils.getMapbox(context, accessToken);
this.id = id;
this.context = context;
@@ -155,6 +159,7 @@ final class MapboxMapController
methodChannel = new MethodChannel(messenger, "plugins.flutter.io/mapbox_maps_" + id);
methodChannel.setMethodCallHandler(this);
this.annotationOrder = annotationOrder;
+ this.annotationConsumeTapEvents = annotationConsumeTapEvents;
}
@Override
@@ -380,8 +385,6 @@ private void enableSymbolManager(@NonNull Style style) {
}
}
-
-
private void enableLineManager(@NonNull Style style) {
if (lineManager == null) {
lineManager = new LineManager(mapView, mapboxMap, style);
@@ -461,6 +464,19 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
result.success(reply);
break;
}
+ case "map#toScreenLocationBatch": {
+ double[] param = (double[])call.argument("coordinates");
+ double[] reply = new double[param.length];
+
+ for (int i = 0; i < param.length; i += 2) {
+ PointF pointf = mapboxMap.getProjection().toScreenLocation(new LatLng(param[i], param[i + 1]));
+ reply[i] = pointf.x;
+ reply[i + 1] = pointf.y;
+ }
+
+ result.success(reply);
+ break;
+ }
case "map#toLatLng": {
Map reply = new HashMap<>();
LatLng latlng = mapboxMap.getProjection().fromScreenLocation(new PointF( ((Double) call.argument("x")).floatValue(), ((Double) call.argument("y")).floatValue()));
@@ -563,14 +579,11 @@ public void onCancel() {
break;
}
case "map#setTelemetryEnabled": {
- final boolean enabled = call.argument("enabled");
- Mapbox.getTelemetry().setUserTelemetryRequestState(enabled);
result.success(null);
break;
}
case "map#getTelemetryEnabled": {
- final TelemetryEnabler.State telemetryState = TelemetryEnabler.retrieveTelemetryStateFromPreferences();
- result.success(telemetryState == TelemetryEnabler.State.ENABLED);
+ result.success(false);
break;
}
case "map#invalidateAmbientCache": {
@@ -606,7 +619,7 @@ public void onError(@NonNull String message) {
for (Symbol symbol : newSymbols) {
symbolId = String.valueOf(symbol.getId());
newSymbolIds.add(symbolId);
- symbols.put(symbolId, new SymbolController(symbol, true, this));
+ symbols.put(symbolId, new SymbolController(symbol, annotationConsumeTapEvents.contains("AnnotationType.symbol"), this));
}
}
}
@@ -614,7 +627,7 @@ public void onError(@NonNull String message) {
break;
}
case "symbols#removeAll": {
- final ArrayList symbolIds = call.argument("symbols");
+ final ArrayList symbolIds = call.argument("ids");
SymbolController symbolController;
List symbolList = new ArrayList();
@@ -676,7 +689,7 @@ public void onError(@NonNull String message) {
Convert.interpretLineOptions(call.argument("options"), lineBuilder);
final Line line = lineBuilder.build();
final String lineId = String.valueOf(line.getId());
- lines.put(lineId, new LineController(line, true, this));
+ lines.put(lineId, new LineController(line, annotationConsumeTapEvents.contains("AnnotationType.line"), this));
result.success(lineId);
break;
}
@@ -686,6 +699,47 @@ public void onError(@NonNull String message) {
result.success(null);
break;
}
+ case "line#addAll": {
+ List newIds = new ArrayList();
+ final List