Skip to content

Commit 019aabe

Browse files
authored
Merge branch 'mapbox:main' into main
2 parents 9890a46 + b6f9d2c commit 019aabe

28 files changed

+891
-96
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
### main
1+
### 2.2.0-rc.1
22

33
* Expose `MapboxStyles.STANDARD_SATELLITE` style.
4+
* `MapDebugOptions` is superseded by `MapWidgetDebugOptions`, expanding existing debug options with the new `light`, `camera`, and `padding` debug options in addition to the new Android-specific options: `layers2DWireframe` and `layers3DWireframe`.
5+
* Bump Maps SDK to 11.6.0-rc.1
46

57
### 2.2.0-beta.1
68

README.md

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Mapbox Maps SDK Flutter SDK
22

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.
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-rc.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

@@ -54,7 +54,7 @@ The Maps Flutter SDK is compatible with applications:
5454

5555
### Configure credentials
5656
To run the Maps Flutter SDK you will need to configure the Mapbox Access Tokens.
57-
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.
57+
Read more about access tokens and public/secret scopes in the platform [Android](https://docs.mapbox.com/android/maps/guides/install/#configure-credentials) or [iOS](https://docs.mapbox.com/ios/maps/guides/install/#step-4-configure-your-public-token) docs.
5858

5959
#### Secret token
6060
To access platform SDKs you will need to create a secret access token with the `Downloads:Read` scope and then:
@@ -69,6 +69,8 @@ To access platform SDKs you will need to create a secret access token with the `
6969
password YOUR_SECRET_MAPBOX_ACCESS_TOKEN
7070
```
7171

72+
To learn more about configuring your secret tokens for iOS, please see step 3 of the [configure credentials section](https://docs.mapbox.com/ios/maps/guides/install/#step-3-configure-your-secret-token) of the iOS Installation Guide.
73+
7274
#### Public token
7375
You can set the access token for Mapbox Maps Flutter SDK(as well as for every Mapbox SDK) via `MapboxOptions`:
7476
```
@@ -129,7 +131,7 @@ Add the following permissions to the manifest:
129131
```
130132

131133
#### iOS
132-
Add the following to the `Runner/Info.plist` to explain why you need access to the location data:
134+
Add the following key/value pair to the `Runner/Info.plist`. In the value field, explain why you need access to location:
133135

134136
```
135137
<key>NSLocationWhenInUseUsageDescription</key>
@@ -148,9 +150,9 @@ void main() {
148150
```
149151

150152
#### MapWidget widget
151-
The `MapWidget` widget provides options to customize the map - you can set `MapOptions`, `CameraOptions`, `styleURL` etc.
153+
The `MapWidget` widget provides options to customize the map - you can set `MapOptions`, `CameraOptions`, `styleURL`, etc.
152154

153-
It also allows or add listeners for various events - related to style loading, map rendering, map loading.
155+
You can also add listeners for various events related to style loading, map rendering, map loading.
154156

155157
#### MapboxMap controller
156158
The `MapboxMap` controller instance is provided with `MapWidget.onMapCreated` callback.
@@ -188,16 +190,16 @@ class FullMapState extends State<FullMap> {
188190
```
189191

190192
## User location
191-
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/user-location/), [iOS](https://docs.mapbox.com/ios/maps/guides/user-location/).
193+
To observe the user's location and show the location indicator on the map use `LocationComponentSettingsInterface` accessible via `MapboxMap.location`.
192194

193-
To observe the user's location and show the location indicator on the map use `LocationComponentSettingsInterface` accessible via `MapboxMap.location`.
195+
For more information, please see the User Location guides in our [Flutter](https://docs.mapbox.com/flutter/maps/guides/user-location), [Android](https://docs.mapbox.com/android/maps/guides/user-location/), and [iOS](https://docs.mapbox.com/ios/maps/guides/user-location/) documentation.
194196

195197
You need to grant location permission prior to using location component (as explained [before](#configure-permissions)).
196198

197199
### Location puck
198200
To customize the appearance of the location puck call `MapboxMap.location.updateSettings` method.
199201

200-
To use the 3D puck with model downloaded from Uri instead of the default 2D puck :
202+
To use the 3D puck with model downloaded from Uri instead of the default 2D puck:
201203

202204
```
203205
mapboxMap.location.updateSettings(LocationComponentSettings(
@@ -210,11 +212,11 @@ To use the 3D puck with model downloaded from Uri instead of the default 2D puck
210212
You can find more examples of customization in the sample [app](example/lib/location.dart).
211213

212214
## Markers and annotations
213-
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/annotations/), [iOS](https://docs.mapbox.com/ios/maps/guides/annotations/).
215+
Additional information is available in our [Flutter](https://docs.mapbox.com/flutter/maps/guides/markers-and-annotations/), [Android](https://docs.mapbox.com/android/maps/guides/annotations/), and [iOS](https://docs.mapbox.com/ios/maps/guides/annotations/) documentation.
214216

215217
You have several options to add annotations on the map.
216218

217-
1. Use the AnnotationManager APIs to create circle/point/polygon/polyline annotations.
219+
1. Use the AnnotationManager APIs to create circle, point, polygon, and polyline annotations.
218220

219221
To create 5 point annotations using custom icon:
220222
```
@@ -235,21 +237,21 @@ You can find more examples of the AnnotationManagers usage in the sample app : [
235237
1. Use style layers. This will require writing more code but is more flexible and provides better performance for the large amount of annotations (e.g. hundreds and thousands of them). More about adding style layers in the [Map styles section](#map-styles).
236238

237239
## Map styles
238-
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/styles/), [iOS](https://docs.mapbox.com/ios/maps/guides/styles/).
240+
Additional information is available in our [Flutter](https://docs.mapbox.com/flutter/maps/guides/styles/), [Android](https://docs.mapbox.com/android/maps/guides/styles/), and [iOS](https://docs.mapbox.com/ios/maps/guides/styles/) documentation.
239241

240242
The Mapbox Maps Flutter SDK allows full customization of the look of the map used in your application.
241243

242244
### Set a style
243-
You can specify the initial style uri at `MapWidget.styleUri`, or load it at runtime using `MapboxMap.loadStyleURI` / `MapboxMap.loadStyleJson` :
245+
You can specify the initial style uri at `MapWidget.styleUri`, or load it at runtime using `MapboxMap.loadStyleURI` / `MapboxMap.loadStyleJson`:
244246

245247
```
246-
mapboxMap.loadStyleURI(Styles.LIGHT);
248+
mapboxMap.loadStyleURI(Styles.LIGHT);
247249
```
248250

249251
### Work with layers
250-
You can familiarize with the concept of sources, layers and their supported types in the platform documentation.
252+
You can familiarize with the concept of sources, layers and their supported types in the documentation for [Flutter](https://docs.mapbox.com/flutter/maps/guides/styles/work-with-layers), [iOS](https://docs.mapbox.com/ios/maps/guides/styles/work-with-layers/), and [Android](https://docs.mapbox.com/android/maps/guides/styles/work-with-layers/).
251253

252-
To add, remove or change a source or a layer use the `MapboxMap.style` object.
254+
To add, remove or change a source or a layer, use the `MapboxMap.style` object.
253255

254256
To add a `GeoJsonSource` and a `LineLayer` using the source :
255257
```
@@ -267,19 +269,21 @@ To add a `GeoJsonSource` and a `LineLayer` using the source :
267269

268270
### Using expressions
269271
You can change the appearance of a layer based on properties in the layer's data source or zoom level.
270-
Refer to the [documentation](https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/) for the description of supported expressions.
272+
Refer to the [documentation](https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/) for the description of supported expressions. You can also learn more in the documentation for [Flutter](https://docs.mapbox.com/flutter/maps/guides/styles/style-layers#work-with-expressions), [iOS](https://docs.mapbox.com/ios/maps/guides/styles/style-layers/#work-with-expressions), and [Android](https://docs.mapbox.com/android/maps/guides/styles/style-layers/#work-with-expressions).
273+
271274
To apply an expression to interpolate gradient color to a line layer:
272275
```
273276
mapboxMap.style.setStyleLayerProperty("layer", "line-gradient",
274277
'["interpolate",["linear"],["line-progress"],0.0,["rgb",6,1,255],0.5,["rgb",0,255,42],0.7,["rgb",255,252,0],1.0,["rgb",255,30,0]]');
275278
```
276279

277280
## Camera and animations
278-
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/camera-and-animation/), [iOS](https://docs.mapbox.com/ios/maps/guides/camera-and-animation/).
281+
Platform docs: [Android](https://docs.mapbox.com/android/maps/guides/camera-and-animation/), [iOS](https://docs.mapbox.com/ios/maps/guides/camera-and-animation/).
282+
279283
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.
280284

281285
### Camera position
282-
You can set the starting camera position using `MapWidget.cameraOptions` :
286+
You can set the starting camera position using `MapWidget.cameraOptions`:
283287

284288
```
285289
MapWidget(
@@ -316,7 +320,7 @@ To start a `flyTo` animation to the specific camera options :
316320
You can find more examples of animations in the sample [app](example/lib/animation.dart).
317321

318322
## User interaction
319-
Platform docs : [Android](https://docs.mapbox.com/android/maps/guides/user-interaction/), [iOS](https://docs.mapbox.com/ios/maps/guides/user-interaction/).
323+
Platform docs: [Android](https://docs.mapbox.com/android/maps/guides/user-interaction/), [iOS](https://docs.mapbox.com/ios/maps/guides/user-interaction/).
320324

321325
Users interacting with the map in your application can explore the map by performing standard gestures.
322326

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.6.0-beta.1"
81+
implementation "com.mapbox.maps:android:11.6.0-rc.1"
8282

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

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

+42-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.mapbox.common.TileRegionError
1010
import com.mapbox.geojson.*
1111
import com.mapbox.maps.EdgeInsets
1212
import com.mapbox.maps.StylePackError
13+
import com.mapbox.maps.debugoptions.MapViewDebugOptions
1314
import com.mapbox.maps.extension.style.expressions.dsl.generated.min
1415
import com.mapbox.maps.extension.style.layers.properties.generated.ProjectionName
1516
import com.mapbox.maps.extension.style.light.LightPosition
@@ -26,6 +27,25 @@ import java.io.ByteArrayOutputStream
2627

2728
// FLT to Android
2829

30+
fun _MapWidgetDebugOptions.toMapViewDebugOptions(): MapViewDebugOptions {
31+
return when (this) {
32+
_MapWidgetDebugOptions.TILE_BORDERS -> MapViewDebugOptions.TILE_BORDERS
33+
_MapWidgetDebugOptions.PARSE_STATUS -> MapViewDebugOptions.PARSE_STATUS
34+
_MapWidgetDebugOptions.TIMESTAMPS -> MapViewDebugOptions.TIMESTAMPS
35+
_MapWidgetDebugOptions.COLLISION -> MapViewDebugOptions.COLLISION
36+
_MapWidgetDebugOptions.OVERDRAW -> MapViewDebugOptions.OVERDRAW
37+
_MapWidgetDebugOptions.STENCIL_CLIP -> MapViewDebugOptions.STENCIL_CLIP
38+
_MapWidgetDebugOptions.DEPTH_BUFFER -> MapViewDebugOptions.DEPTH_BUFFER
39+
_MapWidgetDebugOptions.MODEL_BOUNDS -> MapViewDebugOptions.MODEL_BOUNDS
40+
_MapWidgetDebugOptions.TERRAIN_WIREFRAME -> MapViewDebugOptions.TERRAIN_WIREFRAME
41+
_MapWidgetDebugOptions.LAYERS2DWIREFRAME -> MapViewDebugOptions.LAYERS2_DWIREFRAME
42+
_MapWidgetDebugOptions.LAYERS3DWIREFRAME -> MapViewDebugOptions.LAYERS3_DWIREFRAME
43+
_MapWidgetDebugOptions.LIGHT -> MapViewDebugOptions.LIGHT
44+
_MapWidgetDebugOptions.CAMERA -> MapViewDebugOptions.CAMERA
45+
_MapWidgetDebugOptions.PADDING -> MapViewDebugOptions.PADDING
46+
}
47+
}
48+
2949
fun GlyphsRasterizationMode.toGlyphsRasterizationMode(): com.mapbox.maps.GlyphsRasterizationMode {
3050
return when (this) {
3151
GlyphsRasterizationMode.NO_GLYPHS_RASTERIZED_LOCALLY -> com.mapbox.maps.GlyphsRasterizationMode.NO_GLYPHS_RASTERIZED_LOCALLY
@@ -376,6 +396,26 @@ fun Number.toDevicePixels(context: Context): Float {
376396

377397
// Android to FLT
378398

399+
fun MapViewDebugOptions.toFLTDebugOptions(): _MapWidgetDebugOptions? {
400+
return when (this) {
401+
MapViewDebugOptions.TILE_BORDERS -> _MapWidgetDebugOptions.TILE_BORDERS
402+
MapViewDebugOptions.PARSE_STATUS -> _MapWidgetDebugOptions.PARSE_STATUS
403+
MapViewDebugOptions.TIMESTAMPS -> _MapWidgetDebugOptions.TIMESTAMPS
404+
MapViewDebugOptions.COLLISION -> _MapWidgetDebugOptions.COLLISION
405+
MapViewDebugOptions.OVERDRAW -> _MapWidgetDebugOptions.OVERDRAW
406+
MapViewDebugOptions.STENCIL_CLIP -> _MapWidgetDebugOptions.STENCIL_CLIP
407+
MapViewDebugOptions.DEPTH_BUFFER -> _MapWidgetDebugOptions.DEPTH_BUFFER
408+
MapViewDebugOptions.MODEL_BOUNDS -> _MapWidgetDebugOptions.MODEL_BOUNDS
409+
MapViewDebugOptions.TERRAIN_WIREFRAME -> _MapWidgetDebugOptions.TERRAIN_WIREFRAME
410+
MapViewDebugOptions.LAYERS2_DWIREFRAME -> _MapWidgetDebugOptions.LAYERS2DWIREFRAME
411+
MapViewDebugOptions.LAYERS3_DWIREFRAME -> _MapWidgetDebugOptions.LAYERS3DWIREFRAME
412+
MapViewDebugOptions.LIGHT -> _MapWidgetDebugOptions.LIGHT
413+
MapViewDebugOptions.CAMERA -> _MapWidgetDebugOptions.CAMERA
414+
MapViewDebugOptions.PADDING -> _MapWidgetDebugOptions.PADDING
415+
else -> null
416+
}
417+
}
418+
379419
fun com.mapbox.maps.CanonicalTileID.toFLTCanonicalTileID(): CanonicalTileID {
380420
return CanonicalTileID(z = z.toLong(), x = x.toLong(), y = y.toLong())
381421
}
@@ -571,12 +611,12 @@ fun com.mapbox.maps.StylePackLoadProgress.toFLTStylePackLoadProgress(): StylePac
571611
)
572612
}
573613

574-
fun TilesetDescriptorOptions.toTilesetDescriptorOptions(): com.mapbox.maps.TilesetDescriptorOptions {
614+
fun TilesetDescriptorOptions.toTilesetDescriptorOptions(context: Context): com.mapbox.maps.TilesetDescriptorOptions {
575615
val builder = com.mapbox.maps.TilesetDescriptorOptions.Builder()
576616
.styleURI(styleURI)
577617
.minZoom(minZoom.toByte())
578618
.maxZoom(maxZoom.toByte())
579-
pixelRatio?.let { builder.pixelRatio(it.toFloat()) }
619+
.pixelRatio(pixelRatio?.toFloat() ?: context.resources.displayMetrics.density)
580620
tilesets?.let { builder.tilesets(it) }
581621
stylePackOptions?.let { builder.stylePackOptions(it.toStylePackLoadOptions()) }
582622
extraOptions?.let { builder.extraOptions(it.toValue()) }

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import com.google.gson.Gson
55
import com.mapbox.geojson.Feature
66
import com.mapbox.geojson.Point
7+
import com.mapbox.maps.MapView
78
import com.mapbox.maps.MapboxMap
89
import com.mapbox.maps.TileCacheBudget
910
import com.mapbox.maps.extension.observable.eventdata.MapLoadingErrorEventData
@@ -24,9 +25,14 @@ import com.mapbox.maps.mapbox_maps.pigeons.TileCacheBudgetInTiles
2425
import com.mapbox.maps.mapbox_maps.pigeons.TileCoverOptions
2526
import com.mapbox.maps.mapbox_maps.pigeons.ViewportMode
2627
import com.mapbox.maps.mapbox_maps.pigeons._MapInterface
28+
import com.mapbox.maps.mapbox_maps.pigeons._MapWidgetDebugOptionsBox
2729
import com.mapbox.maps.plugin.delegates.listeners.OnMapLoadErrorListener
2830

29-
class MapInterfaceController(private val mapboxMap: MapboxMap, private val context: Context) : _MapInterface {
31+
class MapInterfaceController(
32+
private val mapboxMap: MapboxMap,
33+
private val mapView: MapView,
34+
private val context: Context
35+
) : _MapInterface {
3036
override fun loadStyleURI(styleURI: String, callback: (Result<Unit>) -> Unit) {
3137
mapboxMap.loadStyleUri(
3238
styleURI,
@@ -111,6 +117,16 @@ class MapInterfaceController(private val mapboxMap: MapboxMap, private val conte
111117
return mapboxMap.getMapOptions().toFLTMapOptions(context)
112118
}
113119

120+
override fun getDebugOptions(): List<_MapWidgetDebugOptionsBox?> {
121+
return mapView.debugOptions.mapNotNull { nativeOption ->
122+
nativeOption.toFLTDebugOptions()?.let { _MapWidgetDebugOptionsBox(it) }
123+
}
124+
}
125+
126+
override fun setDebugOptions(debugOptions: List<_MapWidgetDebugOptionsBox>) {
127+
mapView.debugOptions = debugOptions.map { it.option.toMapViewDebugOptions() }.toSet()
128+
}
129+
114130
override fun getDebug(): List<MapDebugOptions> {
115131
return mapboxMap.getDebug().map { it.toFLTMapDebugOptions() }.toMutableList()
116132
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class MapboxMapController(
131131
styleController = StyleController(context, mapboxMap)
132132
cameraController = CameraController(mapboxMap, context)
133133
projectionController = MapProjectionController(mapboxMap)
134-
mapInterfaceController = MapInterfaceController(mapboxMap, context)
134+
mapInterfaceController = MapInterfaceController(mapboxMap, mapView, context)
135135
animationController = AnimationController(mapboxMap, context)
136136
annotationController = AnnotationController(mapView)
137137
locationComponentController = LocationComponentController(mapView, context)

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/offline/OfflineMapInstanceManager.kt

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.mapbox.maps.mapbox_maps.offline
22

33
import android.content.Context
44
import com.mapbox.common.TileStore
5+
import com.mapbox.maps.MapboxMapsOptions
56
import com.mapbox.maps.mapbox_maps.ProxyBinaryMessenger
67
import com.mapbox.maps.mapbox_maps.pigeons.*
78
import io.flutter.plugin.common.BinaryMessenger
@@ -27,6 +28,7 @@ class OfflineMapInstanceManager(
2728
override fun setupTileStore(channelSuffix: String, filePath: String?) {
2829
val proxy = ProxyBinaryMessenger(messenger, channelSuffix)
2930
val tileStore = filePath?.let { TileStore.create(it) } ?: TileStore.create()
31+
MapboxMapsOptions.tileStore = tileStore
3032
val tileStoreController = TileStoreController(context, messenger, tileStore)
3133
_TileStore.setUp(proxy, tileStoreController)
3234
proxies["tilestore/$channelSuffix"] = proxy
@@ -35,5 +37,6 @@ class OfflineMapInstanceManager(
3537
override fun tearDownTileStore(channelSuffix: String) {
3638
val proxy = proxies["tilestore/$channelSuffix"] ?: return
3739
_TileStore.setUp(proxy, null)
40+
MapboxMapsOptions.tileStore = null
3841
}
3942
}

0 commit comments

Comments
 (0)