Skip to content

Commit 5e92a19

Browse files
evil159pjleonard37shinriyoRelease SDK bot for Maps SDK team
authored
[CP] Prepare release 2.6.0-rc.1 (#857)
* Update README.md for viewport support (#841) * Update README.md (#837) (#842) it is not nullable and it is Point object Co-authored-by: shinriyo <[email protected]> * Align tap propagation behavior on Android and iOS. (#847) * Introduce Interactions API (#748) * Initial implementation of QRF and Featurestate * Add Standard experimental, build out Android * Finish up Android interfaces, general cleanup * Linting updates * Additional lint edits * Clean up type conversions, restore tests * Update for linting * Change toValue back * Update example, some docs cleanup * Revert * Build out geometries * Address review feedback * Add framework for typed interactions * Update generated code * Add map.addInteraction, add Standard featuresets * Update for sanity check * Remove viewport query, general cleanup * Update viewport QRF implementation * Remove FeaturesetQueryTarget, minor updates from review * Update Android interface, some formatting * Make Interactions internal, update implementation * Initial generics implementation * Update Podfile * Update to move _Interactions internal * Update error handling and interfaces * Update for lint * Move interaction to pigeon generation * Expand use of generics, rename --------- Co-authored-by: Release SDK bot for Maps SDK team <[email protected]> * Bump platform SDKs version (#855) * Bump SDK version to 2.6.0-rc.1 (#856) --------- Co-authored-by: Patrick Leonard <[email protected]> Co-authored-by: shinriyo <[email protected]> Co-authored-by: Release SDK bot for Maps SDK team <[email protected]>
1 parent 75d3c87 commit 5e92a19

Some content is hidden

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

41 files changed

+4107
-419
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
# main
1+
### 2.6.0-rc.1
2+
3+
> [!IMPORTANT]
4+
> The iOS minimum deployment target is now iOS 14.0.
5+
6+
* Align tap propagation behavior on Android and iOS.
7+
* Introduce the experimental Interactions API, a toolset that allows you to handle interactions on both layers and basemap features for styles. This API introduces a new concept called `Featureset`, which allows Evolving Basemap styles, such as Standard, to export an abstract set of features, such as POI, buildings, and place labels, regardless of which layers they are rendered on. An `Interaction` can then be targeted to these features, modifying their state when interacted with. For example, you can add a `TapInteraction` to your map which targets the `buildings` `Featureset`. When a user taps on a building, the building will be highlighted and its color will change to blue.
8+
9+
```dart
10+
var tapInteraction = TapInteraction(StandardBuildings(),
11+
(_, feature) {
12+
mapboxMap.setFeatureStateForFeaturesetFeature(feature, StandardBuildingState(highlight: true));
13+
log("Building group: ${feature.group}");
14+
});
15+
mapboxMap.addInteraction(tapInteraction);
16+
```
17+
18+
Specific changes:
19+
* Introduce the experimental `MapboxMap.addInteractions` method, which allows you to add interactions to the map.
20+
* Introduce `TapInteraction` and `LongTapInteraction`, which allow you to add tap and longTap interactions to the map.
21+
* Introduce `FeaturesetDescriptor` -- and convenience descriptors for `StandardBuildings`, `StandardPOIs`, and `StandardPlaceLabels` -- which allow you to describe the featureset you want `Interactions` to target.
22+
* Introduce low-level methods for creating and manipulating interactive features: `queryRenderedFeatures`, `querySourceFeatures`, `setFeatureState`, `getFeatureState`, `removeFeatureState`, `resetFeatureState`
23+
* For more guidance with using these new features see `interactive_features_example.dart`.
24+
* Update Maps SDK to 11.10.0-rc.1
225

326
### 2.6.0-beta.1
427

README.md

Lines changed: 5 additions & 5 deletions
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.10.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.10.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

@@ -37,7 +37,7 @@ Contributions welcome!
3737
| Fill Annotations | :white_check_mark: | :white_check_mark: |
3838
| Snapshotter | :white_check_mark: | :white_check_mark: |
3939
| Offline | :white_check_mark: | :white_check_mark: |
40-
| Viewport | :x: | :x: |
40+
| Viewport | :white_check_mark: | :white_check_mark: |
4141
| Style DSL | :x: | :x: |
4242
| Expression DSL | :x: | :x: |
4343
| View Annotations | :x: | :x: |
@@ -137,7 +137,7 @@ The `MapboxMap` controller instance is provided with `MapWidget.onMapCreated` ca
137137
`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,
138138
query rendered features, etc.
139139

140-
It's organized similarly to the [Android](https://docs.mapbox.com/android/maps/api/11.10.0-beta.1/mapbox-maps-android/com.mapbox.maps/-mapbox-map/) and [iOS](https://docs.mapbox.com/ios/maps/api/11.10.0-beta.1/documentation/mapboxmaps/mapboxmap) counterparts.
140+
It's organized similarly to the [Android](https://docs.mapbox.com/android/maps/api/11.10.0-rc.1/mapbox-maps-android/com.mapbox.maps/-mapbox-map/) and [iOS](https://docs.mapbox.com/ios/maps/api/11.10.0-rc.1/documentation/mapboxmaps/mapboxmap) counterparts.
141141

142142
To interact with the map after it's created store the MapboxMap object somewhere :
143143
```
@@ -204,9 +204,9 @@ To create 5 point annotations using custom icon:
204204
var options = <PointAnnotationOptions>[];
205205
for (var i = 0; i < 5; i++) {
206206
options.add(PointAnnotationOptions(
207-
geometry: createRandomPoint().toJson(), image: list));
207+
geometry: Point.fromJson(createRandomPoint().toJson()), image: list));
208208
}
209-
pointAnnotationManager?.createMulti(options);
209+
pointAnnotationManager.createMulti(options);
210210
});
211211
```
212212
You can find more examples of the AnnotationManagers usage in the sample app : [point annotations](example/lib/point_annotations.dart), [circle annotations](example/lib/circle_annotations.dart), [polygon annotations](example/lib/polygon_annotations.dart), [polyline annotations](example/lib/polyline_annotations.dart).

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (file("$rootDir/gradle/ktlint.gradle").exists() && file("$rootDir/gradle/lint
5959
}
6060

6161
dependencies {
62-
implementation "com.mapbox.maps:android:11.10.0-beta.1"
62+
implementation "com.mapbox.maps:android:11.10.0-rc.1"
6363

6464
implementation "androidx.annotation:annotation:1.5.0"
6565
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"

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

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mapbox.maps.mapbox_maps
22

3+
import android.annotation.SuppressLint
34
import android.content.Context
45
import android.graphics.Bitmap
56
import com.google.gson.Gson
@@ -9,6 +10,7 @@ import com.mapbox.bindgen.Value
910
import com.mapbox.common.TileRegionError
1011
import com.mapbox.geojson.*
1112
import com.mapbox.maps.EdgeInsets
13+
import com.mapbox.maps.MapboxExperimental
1214
import com.mapbox.maps.StylePackError
1315
import com.mapbox.maps.applyDefaultParams
1416
import com.mapbox.maps.debugoptions.MapViewDebugOptions
@@ -19,6 +21,8 @@ import com.mapbox.maps.extension.style.light.generated.directionalLight
1921
import com.mapbox.maps.extension.style.light.generated.flatLight
2022
import com.mapbox.maps.extension.style.projection.generated.Projection
2123
import com.mapbox.maps.extension.style.types.StyleTransition
24+
import com.mapbox.maps.interactions.FeatureState
25+
import com.mapbox.maps.interactions.TypedFeaturesetDescriptor
2226
import com.mapbox.maps.logE
2327
import com.mapbox.maps.mapbox_maps.pigeons.*
2428
import org.json.JSONArray
@@ -263,6 +267,50 @@ fun RenderedQueryOptions.toRenderedQueryOptions(): com.mapbox.maps.RenderedQuery
263267
return com.mapbox.maps.RenderedQueryOptions(layerIds, filter?.toValue())
264268
}
265269

270+
fun FeaturesetFeatureId.toFeaturesetFeatureId(): com.mapbox.maps.FeaturesetFeatureId {
271+
return com.mapbox.maps.FeaturesetFeatureId(id, namespace)
272+
}
273+
274+
@OptIn(MapboxExperimental::class)
275+
fun FeaturesetDescriptor.toTypedFeaturesetDescriptor(): TypedFeaturesetDescriptor<FeatureState, com.mapbox.maps.interactions.FeaturesetFeature<FeatureState>>? {
276+
featuresetId?.let {
277+
return TypedFeaturesetDescriptor.Featureset(
278+
featuresetId, importId
279+
)
280+
} ?: layerId?.let {
281+
return TypedFeaturesetDescriptor.Layer(
282+
layerId
283+
)
284+
}
285+
return null
286+
}
287+
288+
@OptIn(MapboxExperimental::class)
289+
fun Map<String, Any?>.toFeatureState(): com.mapbox.maps.interactions.FeatureState {
290+
val map = this
291+
return FeatureState {
292+
for ((key, value) in map) {
293+
value?.let {
294+
when (value) {
295+
is String -> {
296+
addStringState(key, value)
297+
}
298+
is Long -> {
299+
addLongState(key, value)
300+
}
301+
is Double -> {
302+
addDoubleState(key, value)
303+
}
304+
is Boolean -> {
305+
addBooleanState(key, value)
306+
}
307+
else -> throw (RuntimeException("Unsupported (key, value): ($key, $value)"))
308+
}
309+
}
310+
}
311+
}
312+
}
313+
266314
fun MapDebugOptions.toMapDebugOptions(): com.mapbox.maps.MapDebugOptions {
267315
return com.mapbox.maps.MapDebugOptions.values()[data.ordinal]
268316
}
@@ -379,6 +427,44 @@ fun CameraBoundsOptions.toCameraBoundsOptions(): com.mapbox.maps.CameraBoundsOpt
379427
.minZoom(minZoom)
380428
.build()
381429

430+
fun Geometry.toMap(): Map<String?, Any?> {
431+
return when (this) {
432+
is Point -> mapOf(
433+
"type" to "Point",
434+
"coordinates" to listOf(this.latitude(), this.longitude())
435+
)
436+
is LineString -> mapOf(
437+
"type" to "LineString",
438+
"coordinates" to this.coordinates().map { listOf(it.latitude(), it.longitude()) }
439+
)
440+
is Polygon -> mapOf(
441+
"type" to "Polygon",
442+
"coordinates" to this.coordinates().map { ring ->
443+
ring.map { listOf(it.latitude(), it.longitude()) }
444+
}
445+
)
446+
is MultiPoint -> mapOf(
447+
"type" to "MultiPoint",
448+
"coordinates" to this.coordinates().map { listOf(it.latitude(), it.longitude()) }
449+
)
450+
is MultiLineString -> mapOf(
451+
"type" to "MultiLineString",
452+
"coordinates" to this.coordinates().map { line ->
453+
line.map { listOf(it.latitude(), it.longitude()) }
454+
}
455+
)
456+
is MultiPolygon -> mapOf(
457+
"type" to "MultiPolygon",
458+
"coordinates" to this.coordinates().map { polygon ->
459+
polygon.map { ring ->
460+
ring.map { listOf(it.latitude(), it.longitude()) }
461+
}
462+
}
463+
)
464+
else -> throw IllegalArgumentException("Unsupported geometry type")
465+
}
466+
}
467+
382468
fun Map<String?, Any?>.toGeometry(): Geometry {
383469
when {
384470
this["type"] == "Point" -> {
@@ -504,6 +590,35 @@ fun com.mapbox.maps.QueriedRenderedFeature.toFLTQueriedRenderedFeature(): Querie
504590
return QueriedRenderedFeature(queriedFeature.toFLTQueriedFeature(), layers)
505591
}
506592

593+
fun com.mapbox.maps.FeaturesetFeatureId.toFLTFeaturesetFeatureId(): FeaturesetFeatureId {
594+
return FeaturesetFeatureId(featureId, featureNamespace)
595+
}
596+
597+
fun com.mapbox.maps.FeaturesetDescriptor.toFLTFeaturesetDescriptor(): FeaturesetDescriptor {
598+
return FeaturesetDescriptor(featuresetId, importId, layerId)
599+
}
600+
601+
@SuppressLint("RestrictedApi")
602+
@OptIn(MapboxExperimental::class)
603+
fun com.mapbox.maps.interactions.FeaturesetFeature<FeatureState>.toFLTFeaturesetFeature(): FeaturesetFeature {
604+
return FeaturesetFeature(
605+
id?.toFLTFeaturesetFeatureId(),
606+
descriptor.toFeaturesetDescriptor().toFLTFeaturesetDescriptor(),
607+
geometry.toMap(),
608+
properties.toFilteredMap(),
609+
JSONObject(state.asJsonString()).toFilteredMap()
610+
)
611+
}
612+
613+
@SuppressLint("RestrictedApi")
614+
fun com.mapbox.maps.InteractionContext.toFLTMapContentGestureContext(): MapContentGestureContext {
615+
return MapContentGestureContext(
616+
ScreenCoordinate(screenCoordinate.x, screenCoordinate.y),
617+
coordinateInfo.coordinate,
618+
GestureState.ENDED
619+
)
620+
}
621+
507622
fun com.mapbox.maps.QueriedSourceFeature.toFLTQueriedSourceFeature(): QueriedSourceFeature {
508623
return QueriedSourceFeature(queriedFeature.toFLTQueriedFeature())
509624
}
@@ -594,6 +709,13 @@ fun JSONObject.toMap(): Map<String?, Any?> = keys().asSequence().associateWith {
594709
}
595710
}
596711

712+
@OptIn(MapboxExperimental::class)
713+
fun JSONObject.toFilteredMap(): Map<String, Any?> {
714+
return this.toMap()
715+
.filterKeys { it != null } // Filter out null keys
716+
.mapKeys { it.key!! }
717+
}
718+
597719
fun Number.toLogicalPixels(context: Context): Double {
598720
return this.toDouble() / context.resources.displayMetrics.density
599721
}

0 commit comments

Comments
 (0)