Skip to content

Commit 9890a46

Browse files
authored
Merge branch 'mapbox:main' into main
2 parents 675eb07 + 8eb286c commit 9890a46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+374
-181
lines changed

.circleci/config.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
working_directory: example/android
5555
command: |
5656
flutter build apk
57-
./gradlew app:assembleAndroidTest
58-
./gradlew app:assembleDebug -Ptarget=integration_test/all_test.dart -Pdart-defines="$(echo -n "ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN" | base64 -w 0)"
57+
./gradlew app:assembleAndroidTest --stacktrace
58+
./gradlew app:assembleDebug -Ptarget=integration_test/all_test.dart -Pdart-defines="$(echo -n "ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN" | base64 -w 0)" --stacktrace
5959
- persist_to_workspace:
6060
root: << parameters.workspace-path >>
6161
paths:
@@ -121,6 +121,7 @@ jobs:
121121
122122
popd # to repo root
123123
124+
bundle install
124125
bundle exec fastlane build_examples_tests
125126
- persist_to_workspace:
126127
root: << parameters.workspace-path >>

.fastlane/Fastfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ platform :ios do
1414
team_id: "GJZR2MEM28", # Developer Portal Team ID,
1515
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.maps.FlutterMapsExample"],
1616
targets: ["Runner"],
17-
code_sign_identity: "Apple Development: Machiney McMachineface",
17+
code_sign_identity: "Apple Development: Created via API",
1818
)
1919
update_code_signing_settings(
2020
use_automatic_signing: false,
2121
path: "example/ios/Runner.xcodeproj",
2222
team_id: "GJZR2MEM28", # Developer Portal Team ID,
2323
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.maps.FlutterRunnerTests"],
2424
targets: ["RunnerTests"],
25-
code_sign_identity: "Apple Development: Machiney McMachineface",
25+
code_sign_identity: "Apple Development: Created via API",
2626
)
2727
# build tests archive in the `output_directory` to launch on firebase
2828
run_tests(

CHANGELOG.md

+47
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
### main
2+
3+
* Expose `MapboxStyles.STANDARD_SATELLITE` style.
4+
5+
### 2.2.0-beta.1
6+
7+
* Support local assets for 3D puck and `ModelLayer`. To use a local assets, please specify it with `asset://` scheme in the uri.
8+
* Fix map view crashing upon host activity destruction when using a cached Flutter engine.
9+
* Fix a rare crash happening when map widget is being disposed.
10+
11+
### 2.1.0
12+
13+
* Add ModelLayer API.
14+
* Support for offline map, allowing users to download and store map data on their devices for use in environments with limited or no internet connectivity.
15+
* Layer expressions support. Specify expressions when constructing a layer with all new expression support for layers.
16+
*Before:*
17+
```dart
18+
mapboxMap.style.setStyleLayerProperty("layer", "line-gradient",
19+
'["interpolate",["linear"],["line-progress"],0.0,["rgb",255,0,0],0.4,["rgb",0,255,0],1.0,["rgb",0,0,255]]');
20+
21+
```
22+
*After:*
23+
```dart
24+
LineLayer(
25+
...
26+
lineGradientExpression: [
27+
"interpolate",
28+
["linear"],
29+
["line-progress"],
30+
0.0,
31+
["rgb", 255, 0, 0],
32+
0.4,
33+
["rgb", 0, 255, 0],
34+
1.0,
35+
["rgb", 0, 0, 255]
36+
],
37+
);
38+
```
39+
* Expose `text-occlusion-opacity`, `icon-occlusion-opacity`, `line-occlusion-opacity`, `model-front-cutoff`, `lineZOffset` as experimental.
40+
* Add min/max/default values for most of the style properties.
41+
* Expose `clusterMinPoints` property for `GeoJSONSource`.
42+
* Expose `SlotLayer` and `RasterParticleLayer`.
43+
* Expose `LocationComponentSettings.slot`.
44+
* Add `@experimental` annotation to relevant APIs.
45+
* Expose `LineJoin.NONE`.
46+
* Bump Maps SDK to 11.5.0 for Android and 11.5.1 for iOS.
47+
148
### 2.1.0-rc.1
249

350
* Bump Maps SDK to 11.5.0-rc.1

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
gem "fastlane"
3+
gem "fastlane", "~> 2.221.1"
44

55
plugins_path = File.join(File.dirname(__FILE__), '.fastlane', 'Pluginfile')
66
eval_gemfile(plugins_path) if File.exist?(plugins_path)

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
### License
22

3-
Mapbox Maps Flutter Plugin
3+
Mapbox Maps Flutter SDK
44

55
Copyright © 2022 - 2023 Mapbox, Inc. All rights reserved.
66

77
The software and files in this repository (collectively, “Software”) are licensed under the Mapbox TOS for use only with the relevant Mapbox product(s) listed at www.mapbox.com/pricing. This license allows developers with a current active Mapbox account to use and modify the authorized portions of the Software as needed for use only with the relevant Mapbox product(s) through their Mapbox account in accordance with the Mapbox TOS. This license terminates automatically if a developer no longer has a Mapbox account in good standing or breaches the Mapbox TOS. For the license terms, please see the Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox Product Terms at www.mapbox.com/legal/service-terms. If this Software is a SDK, modifications that change or interfere with marked portions of the code related to billing, accounting, or data collection are not authorized and the SDK sends limited de-identified location and usage data which is used in accordance with the Mapbox TOS. [Updated 2023-01]
88

9-
## Additional Mapbox Maps Flutter Plugin licenses
9+
## Additional Mapbox Maps Flutter SDK licenses
1010

1111
[enum_to_string](https://pub.dev/packages/enum_to_string).
1212

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Mapbox Maps SDK Flutter Plugin
1+
# Mapbox Maps SDK Flutter SDK
22

3-
The Mapbox Maps SDK Flutter Plugin is an officially developed solution from Mapbox that enables use of our latest Maps SDK product (v11.5.0). The plugin allows developers to embed highly customized maps using a Flutter widget on Android and iOS.
3+
The Mapbox Maps SDK Flutter SDK is an officially developed solution from Mapbox that enables use of our latest Maps SDK product (v11.6.0-beta.1). The SDK allows developers to embed highly customized maps using a Flutter widget on Android and iOS.
44

55
Web and desktop are not supported.
66

@@ -44,7 +44,7 @@ Contributions welcome!
4444

4545
## Requirements
4646

47-
The Maps Flutter Plugin is compatible with applications:
47+
The Maps Flutter SDK is compatible with applications:
4848

4949
- Deployed on iOS 12 or higher
5050
- Built using the Android SDK 21 or higher
@@ -53,7 +53,7 @@ The Maps Flutter Plugin is compatible with applications:
5353
## Installation
5454

5555
### Configure credentials
56-
To run the Maps Flutter Plugin you will need to configure the Mapbox Access Tokens.
56+
To run the Maps Flutter SDK you will need to configure the Mapbox Access Tokens.
5757
Read more about access tokens and public/secret scopes at the platform [Android](https://docs.mapbox.com/android/maps/guides/install/#configure-credentials) or [iOS](https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials) docs.
5858

5959
#### Secret token
@@ -70,7 +70,7 @@ To access platform SDKs you will need to create a secret access token with the `
7070
```
7171

7272
#### Public token
73-
You can set the access token for Mapbox Maps Flutter Plugin(as well as for every Mapbox SDK) via `MapboxOptions`:
73+
You can set the access token for Mapbox Maps Flutter SDK(as well as for every Mapbox SDK) via `MapboxOptions`:
7474
```
7575
MapboxOptions.setAccessToken(ACCESS_TOKEN);
7676
```
@@ -107,15 +107,15 @@ String ACCESS_TOKEN = String.fromEnvironment("ACCESS_TOKEN");
107107
```
108108

109109
### Add the dependency
110-
To use the Maps Flutter Plugin add the git dependency to the pubspec.yaml:
110+
To use the Maps Flutter SDK add the git dependency to the pubspec.yaml:
111111

112112
```
113113
dependencies:
114-
mapbox_maps_flutter: ^2.1.0-rc.1
114+
mapbox_maps_flutter: ^2.2.0-beta.1
115115
```
116116

117117
### Configure permissions
118-
You will need to grant location permission in order to use the location component of the Maps Flutter Plugin.
118+
You will need to grant location permission in order to use the location component of the Maps Flutter SDK.
119119

120120
You can use an existing library to request location permission, e.g. with [permission_handler](https://pub.dev/packages/permission_handler) `await Permission.locationWhenInUse.request();` will trigger permission request.
121121

@@ -155,10 +155,10 @@ It also allows or add listeners for various events - related to style loading, m
155155
#### MapboxMap controller
156156
The `MapboxMap` controller instance is provided with `MapWidget.onMapCreated` callback.
157157

158-
`MapboxMap` exposes an entry point to the most of the APIs Maps Flutter Plugin provides. It allows to control the map, camera, styles, observe map events,
158+
`MapboxMap` exposes an entry point to the most of the APIs Maps Flutter SDK provides. It allows to control the map, camera, styles, observe map events,
159159
query rendered features, etc.
160160

161-
It's organized similarly to the [Android](https://docs.mapbox.com/android/maps/api/11.2.0/mapbox-maps-android/com.mapbox.maps/-mapbox-map/) and [iOS](https://docs.mapbox.com/ios/maps/api/11.2.0/documentation/mapboxmaps/mapboxmap) counterparts.
161+
It's organized similarly to the [Android](https://docs.mapbox.com/android/maps/api/11.5.0/mapbox-maps-android/com.mapbox.maps/-mapbox-map/) and [iOS](https://docs.mapbox.com/ios/maps/api/11.5.0/documentation/mapboxmaps/mapboxmap) counterparts.
162162

163163
To interact with the map after it's created store the MapboxMap object somewhere :
164164
```
@@ -237,7 +237,7 @@ You can find more examples of the AnnotationManagers usage in the sample app : [
237237
## Map styles
238238
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/styles/), [iOS](https://docs.mapbox.com/ios/maps/guides/styles/).
239239

240-
The Mapbox Maps Flutter Plugin allows full customization of the look of the map used in your application.
240+
The Mapbox Maps Flutter SDK allows full customization of the look of the map used in your application.
241241

242242
### Set a style
243243
You can specify the initial style uri at `MapWidget.styleUri`, or load it at runtime using `MapboxMap.loadStyleURI` / `MapboxMap.loadStyleJson` :
@@ -276,7 +276,7 @@ To apply an expression to interpolate gradient color to a line layer:
276276

277277
## Camera and animations
278278
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/camera-and-animation/), [iOS](https://docs.mapbox.com/ios/maps/guides/camera-and-animation/).
279-
The camera is the user's viewpoint above the map. The Maps Flutter Plugin provides you with options to set and adjust the camera position, listen for camera changes, get the camera position, and restrict the camera position to set bounds.
279+
The camera is the user's viewpoint above the map. The Maps Flutter SDK provides you with options to set and adjust the camera position, listen for camera changes, get the camera position, and restrict the camera position to set bounds.
280280

281281
### Camera position
282282
You can set the starting camera position using `MapWidget.cameraOptions` :

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ if (file("$rootDir/gradle/ktlint.gradle").exists() && file("$rootDir/gradle/lint
7878
}
7979

8080
dependencies {
81-
implementation "com.mapbox.maps:android:11.5.0-rc.1"
81+
implementation "com.mapbox.maps:android:11.6.0-beta.1"
8282

8383
implementation "androidx.annotation:annotation:1.7.1"
8484
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0"

android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4096M
22
android.useAndroidX=true
33
android.enableJetifier=true

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/LocationComponentController.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import com.mapbox.maps.mapbox_maps.pigeons.*
88
import com.mapbox.maps.plugin.locationcomponent.createDefault2DPuck
99
import com.mapbox.maps.plugin.locationcomponent.location
1010

11-
class LocationComponentController(private val mapView: MapView, private val context: Context) :
12-
_LocationComponentSettingsInterface {
11+
class LocationComponentController(
12+
private val mapView: MapView,
13+
private val context: Context
14+
) : _LocationComponentSettingsInterface {
1315
override fun getSettings(): LocationComponentSettings = mapView.location.toFLT(context)
1416

1517
override fun updateSettings(settings: LocationComponentSettings, useDefaultPuck2DIfNeeded: Boolean) {

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapController.kt

+33-12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.mapbox.maps.mapbox_maps.pigeons._AnimationManager
2626
import com.mapbox.maps.mapbox_maps.pigeons._CameraManager
2727
import com.mapbox.maps.mapbox_maps.pigeons._LocationComponentSettingsInterface
2828
import com.mapbox.maps.mapbox_maps.pigeons._MapInterface
29+
import io.flutter.embedding.android.FlutterActivity
2930
import io.flutter.plugin.common.BinaryMessenger
3031
import io.flutter.plugin.common.MethodCall
3132
import io.flutter.plugin.common.MethodChannel
@@ -71,6 +72,7 @@ class MapboxMapController(
7172
*/
7273
private class LifecycleHelper(
7374
val parentLifecycle: Lifecycle,
75+
val shouldDestroyOnDestroy: Boolean,
7476
) : LifecycleOwner, DefaultLifecycleObserver {
7577

7678
val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)
@@ -103,20 +105,22 @@ class MapboxMapController(
103105
lifecycleRegistry.currentState = Lifecycle.State.CREATED
104106
}
105107

106-
override fun onDestroy(owner: LifecycleOwner) {
107-
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED
108-
}
108+
override fun onDestroy(owner: LifecycleOwner) = propagateDestroyEvent()
109109

110110
fun dispose() {
111111
parentLifecycle.removeObserver(this)
112-
// fires MapView.onStop
113-
lifecycleRegistry.currentState = Lifecycle.State.CREATED
114-
// fires MapView.onDestroy
115-
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED
112+
propagateDestroyEvent()
113+
}
114+
115+
private fun propagateDestroyEvent() {
116+
lifecycleRegistry.currentState = when (shouldDestroyOnDestroy) {
117+
true -> Lifecycle.State.DESTROYED
118+
false -> Lifecycle.State.CREATED
119+
}
116120
}
117121
}
118122

119-
private val lifecycleHelper: LifecycleHelper
123+
private var lifecycleHelper: LifecycleHelper? = null
120124

121125
init {
122126
val mapView = MapView(context, mapInitOptions)
@@ -139,9 +143,6 @@ class MapboxMapController(
139143

140144
changeUserAgent(pluginVersion)
141145

142-
lifecycleHelper = LifecycleHelper(lifecycleProvider.getLifecycle()!!)
143-
ViewTreeLifecycleOwner.set(mapView, lifecycleHelper)
144-
145146
StyleManager.setUp(proxyBinaryMessenger, styleController)
146147
_CameraManager.setUp(proxyBinaryMessenger, cameraController)
147148
Projection.setUp(proxyBinaryMessenger, projectionController)
@@ -163,11 +164,31 @@ class MapboxMapController(
163164
return mapView
164165
}
165166

167+
override fun onFlutterViewAttached(flutterView: View) {
168+
super.onFlutterViewAttached(flutterView)
169+
val context = flutterView.context
170+
val shouldDestroyOnDestroy = when (context is FlutterActivity) {
171+
true -> context.shouldDestroyEngineWithHost()
172+
false -> true
173+
}
174+
lifecycleHelper = LifecycleHelper(lifecycleProvider.getLifecycle()!!, shouldDestroyOnDestroy)
175+
176+
mapView?.let { ViewTreeLifecycleOwner.set(it, lifecycleHelper) }
177+
}
178+
179+
override fun onFlutterViewDetached() {
180+
super.onFlutterViewDetached()
181+
lifecycleHelper?.dispose()
182+
lifecycleHelper = null
183+
ViewTreeLifecycleOwner.set(mapView!!, null)
184+
}
185+
166186
override fun dispose() {
167187
if (mapView == null) {
168188
return
169189
}
170-
lifecycleHelper.dispose()
190+
lifecycleHelper?.dispose()
191+
lifecycleHelper = null
171192
mapView = null
172193
mapboxMap = null
173194
methodChannel.setMethodCallHandler(null)

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapFactory.kt

+2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import com.mapbox.maps.Style
1818
import com.mapbox.maps.ViewportMode
1919
import com.mapbox.maps.applyDefaultParams
2020
import com.mapbox.maps.mapbox_maps.mapping.turf.PointDecoder
21+
import io.flutter.embedding.engine.plugins.FlutterPlugin
2122
import io.flutter.plugin.common.BinaryMessenger
2223
import io.flutter.plugin.common.StandardMessageCodec
2324
import io.flutter.plugin.platform.PlatformView
2425
import io.flutter.plugin.platform.PlatformViewFactory
2526

2627
class MapboxMapFactory(
2728
private val messenger: BinaryMessenger,
29+
private val flutterAssets: FlutterPlugin.FlutterAssets,
2830
private val lifecycleProvider: MapboxMapsPlugin.LifecycleProvider
2931
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
3032

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapsPlugin.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.mapbox.maps.mapbox_maps.pigeons._SnapshotterInstanceManager
1212
import com.mapbox.maps.mapbox_maps.pigeons._TileStoreInstanceManager
1313
import com.mapbox.maps.mapbox_maps.snapshot.SnapshotterInstanceManager
1414
import io.flutter.embedding.engine.plugins.FlutterPlugin
15+
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterAssets
1516
import io.flutter.embedding.engine.plugins.activity.ActivityAware
1617
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
1718
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter
@@ -28,19 +29,19 @@ class MapboxMapsPlugin : FlutterPlugin, ActivityAware {
2829
"plugins.flutter.io/mapbox_maps",
2930
MapboxMapFactory(
3031
flutterPluginBinding.binaryMessenger,
32+
flutterPluginBinding.flutterAssets,
3133
object : LifecycleProvider {
3234
override fun getLifecycle(): Lifecycle? {
3335
return lifecycle
3436
}
3537
}
3638
)
3739
)
38-
39-
setupStaticChannels(flutterPluginBinding.applicationContext, flutterPluginBinding.binaryMessenger)
40+
setupStaticChannels(flutterPluginBinding.applicationContext, flutterPluginBinding.binaryMessenger, flutterPluginBinding.flutterAssets)
4041
}
4142

42-
private fun setupStaticChannels(context: Context, binaryMessenger: BinaryMessenger) {
43-
val optionsController = MapboxOptionsController()
43+
private fun setupStaticChannels(context: Context, binaryMessenger: BinaryMessenger, flutterAssets: FlutterAssets) {
44+
val optionsController = MapboxOptionsController(flutterAssets)
4445
val snapshotterInstanceManager = SnapshotterInstanceManager(context, binaryMessenger)
4546
val offlineMapInstanceManager = OfflineMapInstanceManager(context, binaryMessenger)
4647
val offlineSwitch = OfflineSwitch()

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxOptionsController.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import com.mapbox.common.SettingsServiceFactory
77
import com.mapbox.common.SettingsServiceStorageType
88
import com.mapbox.maps.MapboxMapsOptions
99
import com.mapbox.maps.mapbox_maps.pigeons.*
10+
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterAssets
1011

11-
class MapboxOptionsController : _MapboxMapsOptions, _MapboxOptions {
12+
class MapboxOptionsController(
13+
private val flutterAssets: FlutterAssets
14+
) : _MapboxMapsOptions, _MapboxOptions {
1215
private val settingsService = SettingsServiceFactory.getInstance(SettingsServiceStorageType.PERSISTENT)
1316

1417
override fun getAccessToken(): String {
@@ -39,6 +42,10 @@ class MapboxOptionsController : _MapboxMapsOptions, _MapboxOptions {
3942
return ""
4043
}
4144

45+
override fun getFlutterAssetPath(flutterAssetUri: String?): String? {
46+
return flutterAssetUri?.replace("""^asset://(.+)""".toRegex(), "asset://${flutterAssets.getAssetFilePathBySubpath("$1")}")
47+
}
48+
4249
override fun setAssetPath(path: String) {
4350
// ignored on Android
4451
}

0 commit comments

Comments
 (0)