From 451bc8d84f5a7a6fca9ac5ca25c9635726bf5fa7 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Mon, 12 May 2025 15:10:55 +0300 Subject: [PATCH 1/9] update example gradle --- .../example/android/app/src/profile/AndroidManifest.xml | 3 +-- mapbox_maps_flutter_mobile/example/android/gradle.properties | 3 +++ .../example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- mapbox_maps_flutter_mobile/example/android/settings.gradle | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mapbox_maps_flutter_mobile/example/android/app/src/profile/AndroidManifest.xml b/mapbox_maps_flutter_mobile/example/android/app/src/profile/AndroidManifest.xml index dfa0ba8d3..f880684a6 100644 --- a/mapbox_maps_flutter_mobile/example/android/app/src/profile/AndroidManifest.xml +++ b/mapbox_maps_flutter_mobile/example/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/mapbox_maps_flutter_mobile/example/android/gradle.properties b/mapbox_maps_flutter_mobile/example/android/gradle.properties index 3852c19ca..9b7e91c07 100644 --- a/mapbox_maps_flutter_mobile/example/android/gradle.properties +++ b/mapbox_maps_flutter_mobile/example/android/gradle.properties @@ -2,3 +2,6 @@ org.gradle.jvmargs=-Xmx4096M android.useAndroidX=true android.enableJetifier=false useLocalDependencies=false +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/mapbox_maps_flutter_mobile/example/android/gradle/wrapper/gradle-wrapper.properties b/mapbox_maps_flutter_mobile/example/android/gradle/wrapper/gradle-wrapper.properties index f58dbd5d8..c38a728c4 100644 --- a/mapbox_maps_flutter_mobile/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/mapbox_maps_flutter_mobile/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Apr 30 20:27:36 EEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/mapbox_maps_flutter_mobile/example/android/settings.gradle b/mapbox_maps_flutter_mobile/example/android/settings.gradle index dcd3b479a..34d8421bb 100644 --- a/mapbox_maps_flutter_mobile/example/android/settings.gradle +++ b/mapbox_maps_flutter_mobile/example/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.1" apply false + id "com.android.application" version '8.7.0' apply false id "org.jetbrains.kotlin.android" version "1.8.22" apply false } From 1c6738420d263f9b260946c8c916f065a993d1a3 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Mon, 12 May 2025 16:23:49 +0300 Subject: [PATCH 2/9] fix up --- .../android/gradle/wrapper/gradle-wrapper.properties | 4 +++- mapbox_maps_flutter_v3/.pubignore | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 mapbox_maps_flutter_v3/.pubignore diff --git a/mapbox_maps_flutter_mobile/android/gradle/wrapper/gradle-wrapper.properties b/mapbox_maps_flutter_mobile/android/gradle/wrapper/gradle-wrapper.properties index 111c25e79..09523c0e5 100644 --- a/mapbox_maps_flutter_mobile/android/gradle/wrapper/gradle-wrapper.properties +++ b/mapbox_maps_flutter_mobile/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip diff --git a/mapbox_maps_flutter_v3/.pubignore b/mapbox_maps_flutter_v3/.pubignore new file mode 100644 index 000000000..34924180a --- /dev/null +++ b/mapbox_maps_flutter_v3/.pubignore @@ -0,0 +1,4 @@ +*.lock +**/android/gradlew +**/android/gradlew.bat +**/android/gradle/wrapper/gradle-wrapper.jar \ No newline at end of file From 672d93a2e75a95a93ad4d1d65435a33340d56b73 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Mon, 12 May 2025 17:26:36 +0300 Subject: [PATCH 3/9] wip --- .../example/pubspec.lock | 12 +++++----- .../test/events_test.dart | 7 ++++-- mapbox_maps_flutter_v3/example/pubspec.lock | 12 +++++----- .../example/test/widget_test.dart | 4 ++-- mapbox_maps_flutter_web/example/pubspec.lock | 12 +++++----- .../example/test/widget_test.dart | 4 ++-- .../lib/src/mapbox_maps_flutter_web.dart | 22 +++++++++---------- scripts/check_test_suite.dart | 9 +++++--- 8 files changed, 43 insertions(+), 39 deletions(-) diff --git a/mapbox_maps_flutter_mobile/example/pubspec.lock b/mapbox_maps_flutter_mobile/example/pubspec.lock index 19d810e5d..03e2d7470 100644 --- a/mapbox_maps_flutter_mobile/example/pubspec.lock +++ b/mapbox_maps_flutter_mobile/example/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" benchmark: dependency: transitive description: @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" ffi: dependency: transitive description: @@ -534,10 +534,10 @@ packages: dependency: transitive description: name: webdriver - sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade" + sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.0.4" xdg_directories: dependency: transitive description: diff --git a/mapbox_maps_flutter_mobile/test/events_test.dart b/mapbox_maps_flutter_mobile/test/events_test.dart index d6a3877e4..ee5a3c375 100644 --- a/mapbox_maps_flutter_mobile/test/events_test.dart +++ b/mapbox_maps_flutter_mobile/test/events_test.dart @@ -6,7 +6,9 @@ void main() { final json = { 'timestamp': 1, 'cameraState': { - 'center': {'coordinates': [0, 0]}, + 'center': { + 'coordinates': [0, 0] + }, 'padding': {'top': 0, 'left': 1, 'bottom': 2, 'right': 3}, 'zoom': 11, 'bearing': 0, @@ -15,7 +17,8 @@ void main() { }; var cameraChangedEventData = CameraChangedEventData.fromJson(json); expect(cameraChangedEventData.timestamp, 1); - expect(cameraChangedEventData.cameraState.center.coordinates, Position.of([0, 0])); + expect(cameraChangedEventData.cameraState.center.coordinates, + Position.of([0, 0])); expect(cameraChangedEventData.cameraState.padding.top, 0); expect(cameraChangedEventData.cameraState.padding.left, 1); expect(cameraChangedEventData.cameraState.padding.bottom, 2); diff --git a/mapbox_maps_flutter_v3/example/pubspec.lock b/mapbox_maps_flutter_v3/example/pubspec.lock index 7855744a1..24048737d 100644 --- a/mapbox_maps_flutter_v3/example/pubspec.lock +++ b/mapbox_maps_flutter_v3/example/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" benchmark: dependency: transitive description: @@ -77,10 +77,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" file: dependency: transitive description: @@ -404,10 +404,10 @@ packages: dependency: transitive description: name: webdriver - sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade" + sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.0.4" sdks: dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.27.0" diff --git a/mapbox_maps_flutter_v3/example/test/widget_test.dart b/mapbox_maps_flutter_v3/example/test/widget_test.dart index c4bfe976d..5f3efff37 100644 --- a/mapbox_maps_flutter_v3/example/test/widget_test.dart +++ b/mapbox_maps_flutter_v3/example/test/widget_test.dart @@ -18,8 +18,8 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/mapbox_maps_flutter_web/example/pubspec.lock b/mapbox_maps_flutter_web/example/pubspec.lock index c62789efa..e261180dd 100644 --- a/mapbox_maps_flutter_web/example/pubspec.lock +++ b/mapbox_maps_flutter_web/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" boolean_selector: dependency: transitive description: @@ -53,10 +53,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" file: dependency: transitive description: @@ -294,10 +294,10 @@ packages: dependency: transitive description: name: webdriver - sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade" + sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.0.4" sdks: dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/mapbox_maps_flutter_web/example/test/widget_test.dart b/mapbox_maps_flutter_web/example/test/widget_test.dart index bcec5bab4..df76b5acc 100644 --- a/mapbox_maps_flutter_web/example/test/widget_test.dart +++ b/mapbox_maps_flutter_web/example/test/widget_test.dart @@ -18,8 +18,8 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart index 22deedc59..aaa8ca4c8 100644 --- a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart +++ b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart @@ -23,13 +23,12 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { // Attach the mapDiv to the DOM platformViewRegistry.registerViewFactory(viewType, (int id) { - _mapElement = - document.createElement("div") as HTMLDivElement - ..style.position = 'absolute' - ..style.top = '0' - ..style.bottom = '0' - ..style.height = '100%' - ..style.width = '100%'; + _mapElement = document.createElement("div") as HTMLDivElement + ..style.position = 'absolute' + ..style.top = '0' + ..style.bottom = '0' + ..style.height = '100%' + ..style.width = '100%'; _initMap(); return _mapElement; @@ -38,11 +37,10 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { } _initMap() async { - final link = - document.createElement('link') as HTMLLinkElement - ..rel = 'stylesheet' - ..href = mapboxGlCss - ..type = 'text/css'; + final link = document.createElement('link') as HTMLLinkElement + ..rel = 'stylesheet' + ..href = mapboxGlCss + ..type = 'text/css'; _mapElement.append(link); await link.onLoad.first; diff --git a/scripts/check_test_suite.dart b/scripts/check_test_suite.dart index 316a4d559..c4ad7b23f 100644 --- a/scripts/check_test_suite.dart +++ b/scripts/check_test_suite.dart @@ -32,15 +32,18 @@ void main() { .where((testFile) => !includedTestFiles.contains(testFile)) .toList(); - missingTests.remove('all_test.dart'); // Exclude the aggregated test suite file itself + missingTests + .remove('all_test.dart'); // Exclude the aggregated test suite file itself if (missingTests.isNotEmpty) { - print('The following test files are missing from the aggregated test suite:'); + print( + 'The following test files are missing from the aggregated test suite:'); for (var missingTest in missingTests) { print(missingTest); } print(''); - print('Import the missing test files in the integration_test/all_test.dart.'); + print( + 'Import the missing test files in the integration_test/all_test.dart.'); print("Don't forget to invoke the main function of the test file as well."); exit(1); // Exit with error code 1 if there are missing tests } else { From 41d18b660bb55f04895c89284aeb67c55d3b3174 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Tue, 13 May 2025 16:29:15 +0300 Subject: [PATCH 4/9] wip --- .../lib/mapbox_maps_flutter_interface.dart | 9 +-- .../lib/src/callbacks.dart | 2 - ...apbox_maps_flutter_platform_interface.dart | 6 +- .../lib/src/types/camera_options.dart | 35 +++++++++++ .../lib/src/types/camera_state.dart | 59 ++++++++++++++++++ .../lib/src/types/edge_insets.dart | 61 +++++++++++++++++++ .../lib/src/types/screen_coordinate.dart | 30 +++++++++ mapbox_maps_flutter_interface/pubspec.yaml | 1 + .../maps/mapbox_maps/pigeons/MapInterfaces.kt | 22 +++++-- .../Generated/CircleAnnotationMessenger.swift | 2 +- .../lib/src/map_widget.dart | 10 ++- 11 files changed, 222 insertions(+), 15 deletions(-) create mode 100644 mapbox_maps_flutter_interface/lib/src/types/camera_options.dart create mode 100644 mapbox_maps_flutter_interface/lib/src/types/camera_state.dart create mode 100644 mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart create mode 100644 mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart diff --git a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart index cfcbba884..c7a7bfceb 100644 --- a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart +++ b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart @@ -1,6 +1,7 @@ library; -import 'package:flutter/cupertino.dart'; - -part 'src/mapbox_maps_flutter_platform_interface.dart'; -part 'src/callbacks.dart'; +export 'src/types/camera_options.dart'; +export 'src/types/camera_state.dart'; +export 'src/types/edge_insets.dart'; +export 'src/types/screen_coordinate.dart'; +export 'src/mapbox_maps_flutter_platform_interface.dart'; diff --git a/mapbox_maps_flutter_interface/lib/src/callbacks.dart b/mapbox_maps_flutter_interface/lib/src/callbacks.dart index 815e6a300..8b1378917 100644 --- a/mapbox_maps_flutter_interface/lib/src/callbacks.dart +++ b/mapbox_maps_flutter_interface/lib/src/callbacks.dart @@ -1,3 +1 @@ -part of 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; -typedef OnPlatformViewCreated = void Function(int id); diff --git a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart index d5f49955c..4449fb0f9 100644 --- a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart +++ b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart @@ -1,4 +1,6 @@ -part of 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; +import 'package:flutter/widgets.dart'; + +import 'types/camera_options.dart'; abstract base class MapboxMapsFlutterPlatform { static MapboxMapsFlutterPlatform? _instance; @@ -38,5 +40,5 @@ abstract base class MapboxMapsFlutterPlatform { /// /// This method is responsible for creating the widget that integrates /// with the underlying platform's view system to render the map. - Widget buildView(); + Widget buildView({CameraOptions? cameraOptions}); } diff --git a/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart b/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart new file mode 100644 index 000000000..aed1d4e84 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart @@ -0,0 +1,35 @@ +import 'package:mapbox_maps_flutter_interface/src/types/edge_insets.dart'; +import 'package:mapbox_maps_flutter_interface/src/types/screen_coordinate.dart'; +import 'package:turf/turf.dart' show Point; + +/// Represents the options for configuring the camera's position and view. +class CameraOptions { + /// The geographical center point of the camera. + Point? center; + + /// The padding around the camera view. + MbxEdgeInsets? padding; + + /// Point of reference for `zoom` and `angle`, assuming an origin at the + /// top-left corner of the view. + ScreenCoordinate? anchor; + + /// Zero-based zoom level. Constrained to the minimum and maximum zoom + /// levels. + double? zoom; + + /// Bearing, measured in degrees from true north. Wrapped to [0, 360). + double? bearing; + + /// Pitch toward the horizon measured in degrees. + double? pitch; + + CameraOptions({ + this.center, + this.padding, + this.anchor, + this.zoom, + this.bearing, + this.pitch, + }); +} diff --git a/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart b/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart new file mode 100644 index 000000000..0f82d6307 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart @@ -0,0 +1,59 @@ +import 'package:flutter/foundation.dart'; +import 'package:mapbox_maps_flutter_interface/src/types/edge_insets.dart'; +import 'package:turf/turf.dart' show Point; + +/// Represents the state of the camera in the map. +@immutable +class CameraState { + /// Creates a [CameraState] instance. + const CameraState({ + required this.center, + required this.padding, + required this.zoom, + required this.pitch, + required this.bearing, + }); + + /// The geographical center point of the camera's position. + final Point center; + + /// The padding around the camera's viewport in pixels. + /// This is typically used to adjust the visible region of the map. + final MbxEdgeInsets padding; + + /// The zoom level of the camera. + /// A higher zoom level means a closer view of the map. + final double zoom; + + /// The pitch (tilt) of the camera in degrees. + /// A higher pitch value tilts the camera view. + final double pitch; + + /// The bearing (rotation) of the camera in degrees. + /// A bearing of 0 means the map is oriented north. + final double bearing; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CameraState && + runtimeType == other.runtimeType && + center == other.center && + padding == other.padding && + zoom == other.zoom && + pitch == other.pitch && + bearing == other.bearing; + + @override + int get hashCode => + center.hashCode ^ + padding.hashCode ^ + zoom.hashCode ^ + pitch.hashCode ^ + bearing.hashCode; + + @override + String toString() { + return 'CameraState(center: $center, padding: $padding, zoom: $zoom, pitch: $pitch, bearing: $bearing)'; + } +} diff --git a/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart b/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart new file mode 100644 index 000000000..0e7cb53fc --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart @@ -0,0 +1,61 @@ +/// Represents immutable edge insets, typically used for padding or margins. +/// This class defines the distances from the edges of a rectangle. +class MbxEdgeInsets { + /// The distance from the top edge. + final double top; + + /// The distance from the left edge. + final double left; + + /// The distance from the bottom edge. + final double bottom; + + /// The distance from the right edge. + final double right; + + /// Creates an immutable [MbxEdgeInsets] instance. + /// + /// All parameters are required and must not be null. + const MbxEdgeInsets({ + required this.top, + required this.left, + required this.bottom, + required this.right, + }); + + /// Creates an [MbxEdgeInsets] instance with all edges set to the same value. + const MbxEdgeInsets.all(double value) + : top = value, + left = value, + bottom = value, + right = value; + + /// Creates an [MbxEdgeInsets] instance with symmetric vertical and horizontal values. + const MbxEdgeInsets.symmetric({ + double vertical = 0.0, + double horizontal = 0.0, + }) : top = vertical, + bottom = vertical, + left = horizontal, + right = horizontal; + + /// Returns a string representation of the edge insets. + @override + String toString() { + return 'MbxEdgeInsets(top: $top, left: $left, bottom: $bottom, right: $right)'; + } + + /// Compares two [MbxEdgeInsets] instances for equality. + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! MbxEdgeInsets) return false; + return top == other.top && + left == other.left && + bottom == other.bottom && + right == other.right; + } + + @override + int get hashCode => Object.hash(top, left, bottom, right); +} diff --git a/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart b/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart new file mode 100644 index 000000000..2ece99817 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart @@ -0,0 +1,30 @@ +import 'package:flutter/foundation.dart'; + +/// Describes the coordinate on the screen, measured from top to bottom and from left to right. +/// +/// Note: The `map` uses screen coordinate units measured in `logical pixels`. +@immutable +class ScreenCoordinate { + final double x; + final double y; + + /// Creates a [ScreenCoordinate] instance. + const ScreenCoordinate({ + required this.x, + required this.y, + }); + + @override + String toString() => 'ScreenCoordinate(x: $x, y: $y)'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ScreenCoordinate && + runtimeType == other.runtimeType && + x == other.x && + y == other.y; + + @override + int get hashCode => x.hashCode ^ y.hashCode; +} diff --git a/mapbox_maps_flutter_interface/pubspec.yaml b/mapbox_maps_flutter_interface/pubspec.yaml index ffbf8b029..74180c21e 100644 --- a/mapbox_maps_flutter_interface/pubspec.yaml +++ b/mapbox_maps_flutter_interface/pubspec.yaml @@ -12,6 +12,7 @@ resolution: workspace dependencies: flutter: sdk: flutter + turf: ^0.0.10 dev_dependencies: flutter_test: diff --git a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt index 1f762995b..b24d14502 100644 --- a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt +++ b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt @@ -258,6 +258,20 @@ enum class ViewAnnotationAnchor(val raw: Int) { } } +/** Selects the base of the model. Some modes might require precomputed elevation data in the tileset. */ +enum class ModelElevationReference(val raw: Int) { + /** Elevated rendering is enabled. Use this mode to elevate lines relative to the sea level. */ + SEA(0), + /** Elevated rendering is enabled. Use this mode to elevate lines relative to the ground's height below them. */ + GROUND(1); + + companion object { + fun ofRaw(raw: Int): ModelElevationReference? { + return values().firstOrNull { it.raw == raw } + } + } +} + /** The type of interaction, either tap/click or longTap/longClick */ enum class _InteractionType(val raw: Int) { /** A short tap or click */ @@ -2876,17 +2890,17 @@ private open class MapInterfacesPigeonCodec : StandardMessageCodec() { } 160.toByte() -> { return (readValue(buffer) as? List)?.let { - MbxEdgeInsets.fromList(it) + MbxEdgeInsetsDecoder.fromList(it) } } 161.toByte() -> { return (readValue(buffer) as? List)?.let { - CameraOptions.fromList(it) + CameraOptionsDecoder.fromList(it) } } 162.toByte() -> { return (readValue(buffer) as? List)?.let { - CameraState.fromList(it) + CameraStateDecoder.fromList(it) } } 163.toByte() -> { @@ -2931,7 +2945,7 @@ private open class MapInterfacesPigeonCodec : StandardMessageCodec() { } 171.toByte() -> { return (readValue(buffer) as? List)?.let { - ScreenCoordinate.fromList(it) + ScreenCoordinateDecoder.fromList(it) } } 172.toByte() -> { diff --git a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift index 977fdf67b..84b296ade 100644 --- a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift +++ b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift @@ -10,7 +10,7 @@ import Foundation #else #error("Unsupported platform.") #endif -import struct Turf.Point +import struct Turf.Point; /// Error class for passing custom error details to Dart side. final class CircleAnnotationMessengerError: Error { diff --git a/mapbox_maps_flutter_v3/lib/src/map_widget.dart b/mapbox_maps_flutter_v3/lib/src/map_widget.dart index ec6181ee7..11fff3b7b 100644 --- a/mapbox_maps_flutter_v3/lib/src/map_widget.dart +++ b/mapbox_maps_flutter_v3/lib/src/map_widget.dart @@ -3,10 +3,16 @@ part of 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; class MapWidget extends StatelessWidget { final MapboxMapsFlutterPlatform _platform; - MapWidget({super.key}) : _platform = MapboxMapsFlutterPlatform.instance; + MapWidget({ + super.key, + this.cameraOptions, + }) : _platform = MapboxMapsFlutterPlatform.instance; + + /// The initial Camera options when creating a MapWidget. + final CameraOptions? cameraOptions; @override Widget build(BuildContext context) { - return _platform.buildView(); + return _platform.buildView(cameraOptions: cameraOptions); } } From ce64a428fa1c52c5225f0066f5d4661e6a1dc5c2 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Wed, 14 May 2025 15:12:23 +0300 Subject: [PATCH 5/9] support setting camera in Map init --- .../lib/mapbox_maps_flutter_interface.dart | 12 +- ...apbox_maps_flutter_platform_interface.dart | 2 +- .../platform_interface_data_types.dart | 279 ++++++++++++++++++ .../lib/src/turf_adapter.dart | 19 ++ .../lib/src/types/camera_options.dart | 35 --- .../lib/src/types/camera_state.dart | 59 ---- .../lib/src/types/edge_insets.dart | 61 ---- .../lib/src/types/screen_coordinate.dart | 30 -- .../maps/mapbox_maps/pigeons/MapInterfaces.kt | 241 +-------------- .../pigeons/PlatformInterfaceDataTypes.kt | 239 +++++++++++++++ .../integration_test/animation_test.dart | 3 + .../example/integration_test/camera_test.dart | 3 + .../integration_test/empty_map_widget.dart | 2 + .../integration_test/gestures_test.dart | 3 + .../interactive_features_test.dart | 2 + .../integration_test/map_interface_test.dart | 3 + .../snapshotter/snapshotter_test.dart | 4 +- .../integration_test/viewport_test.dart | 2 + .../example/lib/animated_route_example.dart | 2 + .../example/lib/animation_example.dart | 2 + .../example/lib/camera_example.dart | 2 + .../lib/circle_annotations_example.dart | 2 + .../example/lib/cluster_example.dart | 2 + .../example/lib/edit_polygon_example.dart | 2 + .../example/lib/full_map_example.dart | 2 + .../example/lib/geojson_line_example.dart | 3 +- .../example/lib/image_source_example.dart | 2 + .../example/lib/map_interface_example.dart | 2 + .../example/lib/model_layer_example.dart | 3 + .../lib/model_layer_interactions_example.dart | 3 + .../example/lib/offline_map_example.dart | 2 + .../example/lib/ornaments_example.dart | 2 + .../lib/point_annotations_example.dart | 2 + .../lib/polygon_annotations_example.dart | 2 + .../lib/polyline_annotations_example.dart | 4 +- .../example/lib/spinning_globe_example.dart | 4 +- .../lib/standard_style_import_example.dart | 3 + .../standard_style_interactions_example.dart | 3 + .../example/lib/tile_json_example.dart | 3 +- .../example/lib/traffic_layer_example.dart | 2 + .../lib/traffic_route_line_example.dart | 4 +- .../lib/vector_tile_source_example.dart | 2 + .../Generated/CircleAnnotationMessenger.swift | 2 +- .../Classes/Generated/MapInterfaces.swift | 189 +----------- .../PlatformInterfaceDataTypes.swift | 209 +++++++++++++ .../lib/src/mapbox_map.dart | 11 + .../lib/src/mapbox_maps_flutter_mobile.dart | 6 +- .../lib/src/pigeons/map_interfaces.dart | 274 ----------------- .../lib/src/turf_adapters.dart | 4 + mapbox_maps_flutter_mobile/pubspec.yaml | 1 - .../xcshareddata/swiftpm/Package.resolved | 12 +- .../xcshareddata/swiftpm/Package.resolved | 12 +- mapbox_maps_flutter_v3/example/lib/main.dart | 7 +- mapbox_maps_flutter_v3/example/lib/utils.dart | 6 + .../lib/mapbox_maps_flutter_v3.dart | 9 +- .../lib/src/map_widget.dart | 9 +- .../lib/src/mapbox_options.dart | 2 +- mapbox_maps_flutter_web/example/pubspec.lock | 80 +++++ .../lib/src/mapbox_maps_flutter_web.dart | 2 +- 59 files changed, 979 insertions(+), 915 deletions(-) create mode 100644 mapbox_maps_flutter_interface/lib/src/pigeons/platform_interface_data_types.dart create mode 100644 mapbox_maps_flutter_interface/lib/src/turf_adapter.dart delete mode 100644 mapbox_maps_flutter_interface/lib/src/types/camera_options.dart delete mode 100644 mapbox_maps_flutter_interface/lib/src/types/camera_state.dart delete mode 100644 mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart delete mode 100644 mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart create mode 100644 mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt create mode 100644 mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/PlatformInterfaceDataTypes.swift create mode 100644 mapbox_maps_flutter_v3/example/lib/utils.dart diff --git a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart index c7a7bfceb..354b2587e 100644 --- a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart +++ b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart @@ -1,7 +1,9 @@ -library; +library mapbox_maps_flutter_interface; -export 'src/types/camera_options.dart'; -export 'src/types/camera_state.dart'; -export 'src/types/edge_insets.dart'; -export 'src/types/screen_coordinate.dart'; export 'src/mapbox_maps_flutter_platform_interface.dart'; +export 'package:turf/helpers.dart'; + +import 'package:turf/turf.dart'; + +part 'src/pigeons/platform_interface_data_types.dart'; +part 'src/turf_adapter.dart'; diff --git a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart index 4449fb0f9..89accff0e 100644 --- a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart +++ b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -import 'types/camera_options.dart'; +import '../mapbox_maps_flutter_interface.dart'; abstract base class MapboxMapsFlutterPlatform { static MapboxMapsFlutterPlatform? _instance; diff --git a/mapbox_maps_flutter_interface/lib/src/pigeons/platform_interface_data_types.dart b/mapbox_maps_flutter_interface/lib/src/pigeons/platform_interface_data_types.dart new file mode 100644 index 000000000..4a5c8fa08 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/pigeons/platform_interface_data_types.dart @@ -0,0 +1,279 @@ +// Autogenerated from Pigeon (v25.2.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +part of mapbox_maps_flutter_interface; + +/// Describes the coordinate on the screen, measured from top to bottom and from left to right. +/// Note: the `map` uses screen coordinate units measured in `logical pixels`. +class ScreenCoordinate { + ScreenCoordinate({ + required this.x, + required this.y, + }); + + /// A value representing the x position of this coordinate. + double x; + + /// A value representing the y position of this coordinate. + double y; + + List _toList() { + return [ + x, + y, + ]; + } + + Object encode() { + return _toList(); + } + + static ScreenCoordinate decode(Object result) { + result as List; + return ScreenCoordinate( + x: result[0]! as double, + y: result[1]! as double, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ScreenCoordinate || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return x == other.x && y == other.y; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + +/// The distance on each side between rectangles, when one is contained into other. +/// +/// All fields' values are in `logical pixel` units. +class MbxEdgeInsets { + MbxEdgeInsets({ + required this.top, + required this.left, + required this.bottom, + required this.right, + }); + + /// Padding from the top. + double top; + + /// Padding from the left. + double left; + + /// Padding from the bottom. + double bottom; + + /// Padding from the right. + double right; + + List _toList() { + return [ + top, + left, + bottom, + right, + ]; + } + + Object encode() { + return _toList(); + } + + static MbxEdgeInsets decode(Object result) { + result as List; + return MbxEdgeInsets( + top: result[0]! as double, + left: result[1]! as double, + bottom: result[2]! as double, + right: result[3]! as double, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! MbxEdgeInsets || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return top == other.top && + left == other.left && + bottom == other.bottom && + right == other.right; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + +/// Various options for describing the viewpoint of a camera. All fields are +/// optional. +/// +/// Anchor and center points are mutually exclusive, with preference for the +/// center point when both are set. +class CameraOptions { + CameraOptions({ + this.center, + this.padding, + this.anchor, + this.zoom, + this.bearing, + this.pitch, + }); + + /// Coordinate at the center of the camera. + Point? center; + + /// Padding around the interior of the view that affects the frame of + /// reference for `center`. + MbxEdgeInsets? padding; + + /// Point of reference for `zoom` and `angle`, assuming an origin at the + /// top-left corner of the view. + ScreenCoordinate? anchor; + + /// Zero-based zoom level. Constrained to the minimum and maximum zoom + /// levels. + double? zoom; + + /// Bearing, measured in degrees from true north. Wrapped to [0, 360). + double? bearing; + + /// Pitch toward the horizon measured in degrees. + double? pitch; + + List _toList() { + return [ + center, + padding, + anchor, + zoom, + bearing, + pitch, + ]; + } + + Object encode() { + return _toList(); + } + + static CameraOptions decode(Object result) { + result as List; + return CameraOptions( + center: result[0] as Point?, + padding: result[1] as MbxEdgeInsets?, + anchor: result[2] as ScreenCoordinate?, + zoom: result[3] as double?, + bearing: result[4] as double?, + pitch: result[5] as double?, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! CameraOptions || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return center == other.center && + padding == other.padding && + anchor == other.anchor && + zoom == other.zoom && + bearing == other.bearing && + pitch == other.pitch; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + +/// Describes the viewpoint of a camera. +class CameraState { + CameraState({ + required this.center, + required this.padding, + required this.zoom, + required this.bearing, + required this.pitch, + }); + + /// Coordinate at the center of the camera. + Point center; + + /// Padding around the interior of the view that affects the frame of + /// reference for `center`. + MbxEdgeInsets padding; + + /// Zero-based zoom level. Constrained to the minimum and maximum zoom + /// levels. + double zoom; + + /// Bearing, measured in degrees from true north. Wrapped to [0, 360). + double bearing; + + /// Pitch toward the horizon measured in degrees. + double pitch; + + List _toList() { + return [ + center, + padding, + zoom, + bearing, + pitch, + ]; + } + + Object encode() { + return _toList(); + } + + static CameraState decode(Object result) { + result as List; + return CameraState( + center: result[0]! as Point, + padding: result[1]! as MbxEdgeInsets, + zoom: result[2]! as double, + bearing: result[3]! as double, + pitch: result[4]! as double, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! CameraState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return center == other.center && + padding == other.padding && + zoom == other.zoom && + bearing == other.bearing && + pitch == other.pitch; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} diff --git a/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart b/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart new file mode 100644 index 000000000..cf78ea479 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart @@ -0,0 +1,19 @@ +part of 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; + +// final class Point extends turf.Point { +// Point({super.bbox, required super.coordinates}); + +// factory Point.fromJson(Map json) { +// final turfPoint = turf.Point.fromJson(json); +// return Point(bbox: turfPoint.bbox, coordinates: turfPoint.coordinates); +// } + +// static Point decode(Object result) { +// var map = (result is List) ? result.first : result; +// return Point.fromJson((map as Map).cast()); +// } + +// Object encode() { +// return [toJson()]; +// } +// } diff --git a/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart b/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart deleted file mode 100644 index aed1d4e84..000000000 --- a/mapbox_maps_flutter_interface/lib/src/types/camera_options.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:mapbox_maps_flutter_interface/src/types/edge_insets.dart'; -import 'package:mapbox_maps_flutter_interface/src/types/screen_coordinate.dart'; -import 'package:turf/turf.dart' show Point; - -/// Represents the options for configuring the camera's position and view. -class CameraOptions { - /// The geographical center point of the camera. - Point? center; - - /// The padding around the camera view. - MbxEdgeInsets? padding; - - /// Point of reference for `zoom` and `angle`, assuming an origin at the - /// top-left corner of the view. - ScreenCoordinate? anchor; - - /// Zero-based zoom level. Constrained to the minimum and maximum zoom - /// levels. - double? zoom; - - /// Bearing, measured in degrees from true north. Wrapped to [0, 360). - double? bearing; - - /// Pitch toward the horizon measured in degrees. - double? pitch; - - CameraOptions({ - this.center, - this.padding, - this.anchor, - this.zoom, - this.bearing, - this.pitch, - }); -} diff --git a/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart b/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart deleted file mode 100644 index 0f82d6307..000000000 --- a/mapbox_maps_flutter_interface/lib/src/types/camera_state.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:mapbox_maps_flutter_interface/src/types/edge_insets.dart'; -import 'package:turf/turf.dart' show Point; - -/// Represents the state of the camera in the map. -@immutable -class CameraState { - /// Creates a [CameraState] instance. - const CameraState({ - required this.center, - required this.padding, - required this.zoom, - required this.pitch, - required this.bearing, - }); - - /// The geographical center point of the camera's position. - final Point center; - - /// The padding around the camera's viewport in pixels. - /// This is typically used to adjust the visible region of the map. - final MbxEdgeInsets padding; - - /// The zoom level of the camera. - /// A higher zoom level means a closer view of the map. - final double zoom; - - /// The pitch (tilt) of the camera in degrees. - /// A higher pitch value tilts the camera view. - final double pitch; - - /// The bearing (rotation) of the camera in degrees. - /// A bearing of 0 means the map is oriented north. - final double bearing; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is CameraState && - runtimeType == other.runtimeType && - center == other.center && - padding == other.padding && - zoom == other.zoom && - pitch == other.pitch && - bearing == other.bearing; - - @override - int get hashCode => - center.hashCode ^ - padding.hashCode ^ - zoom.hashCode ^ - pitch.hashCode ^ - bearing.hashCode; - - @override - String toString() { - return 'CameraState(center: $center, padding: $padding, zoom: $zoom, pitch: $pitch, bearing: $bearing)'; - } -} diff --git a/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart b/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart deleted file mode 100644 index 0e7cb53fc..000000000 --- a/mapbox_maps_flutter_interface/lib/src/types/edge_insets.dart +++ /dev/null @@ -1,61 +0,0 @@ -/// Represents immutable edge insets, typically used for padding or margins. -/// This class defines the distances from the edges of a rectangle. -class MbxEdgeInsets { - /// The distance from the top edge. - final double top; - - /// The distance from the left edge. - final double left; - - /// The distance from the bottom edge. - final double bottom; - - /// The distance from the right edge. - final double right; - - /// Creates an immutable [MbxEdgeInsets] instance. - /// - /// All parameters are required and must not be null. - const MbxEdgeInsets({ - required this.top, - required this.left, - required this.bottom, - required this.right, - }); - - /// Creates an [MbxEdgeInsets] instance with all edges set to the same value. - const MbxEdgeInsets.all(double value) - : top = value, - left = value, - bottom = value, - right = value; - - /// Creates an [MbxEdgeInsets] instance with symmetric vertical and horizontal values. - const MbxEdgeInsets.symmetric({ - double vertical = 0.0, - double horizontal = 0.0, - }) : top = vertical, - bottom = vertical, - left = horizontal, - right = horizontal; - - /// Returns a string representation of the edge insets. - @override - String toString() { - return 'MbxEdgeInsets(top: $top, left: $left, bottom: $bottom, right: $right)'; - } - - /// Compares two [MbxEdgeInsets] instances for equality. - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - if (other is! MbxEdgeInsets) return false; - return top == other.top && - left == other.left && - bottom == other.bottom && - right == other.right; - } - - @override - int get hashCode => Object.hash(top, left, bottom, right); -} diff --git a/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart b/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart deleted file mode 100644 index 2ece99817..000000000 --- a/mapbox_maps_flutter_interface/lib/src/types/screen_coordinate.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:flutter/foundation.dart'; - -/// Describes the coordinate on the screen, measured from top to bottom and from left to right. -/// -/// Note: The `map` uses screen coordinate units measured in `logical pixels`. -@immutable -class ScreenCoordinate { - final double x; - final double y; - - /// Creates a [ScreenCoordinate] instance. - const ScreenCoordinate({ - required this.x, - required this.y, - }); - - @override - String toString() => 'ScreenCoordinate(x: $x, y: $y)'; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is ScreenCoordinate && - runtimeType == other.runtimeType && - x == other.x && - y == other.y; - - @override - int get hashCode => x.hashCode ^ y.hashCode; -} diff --git a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt index b24d14502..8b1d1730e 100644 --- a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt +++ b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/MapInterfaces.kt @@ -258,20 +258,6 @@ enum class ViewAnnotationAnchor(val raw: Int) { } } -/** Selects the base of the model. Some modes might require precomputed elevation data in the tileset. */ -enum class ModelElevationReference(val raw: Int) { - /** Elevated rendering is enabled. Use this mode to elevate lines relative to the sea level. */ - SEA(0), - /** Elevated rendering is enabled. Use this mode to elevate lines relative to the ground's height below them. */ - GROUND(1); - - companion object { - fun ofRaw(raw: Int): ModelElevationReference? { - return values().firstOrNull { it.raw == raw } - } - } -} - /** The type of interaction, either tap/click or longTap/longClick */ enum class _InteractionType(val raw: Int) { /** A short tap or click */ @@ -706,186 +692,6 @@ data class TileCoverOptions( override fun hashCode(): Int = toList().hashCode() } -/** - * The distance on each side between rectangles, when one is contained into other. - * - * All fields' values are in `logical pixel` units. - * - * Generated class from Pigeon that represents data sent in messages. - */ -data class MbxEdgeInsets( - /** Padding from the top. */ - val top: Double, - /** Padding from the left. */ - val left: Double, - /** Padding from the bottom. */ - val bottom: Double, - /** Padding from the right. */ - val right: Double -) { - companion object { - fun fromList(pigeonVar_list: List): MbxEdgeInsets { - val top = pigeonVar_list[0] as Double - val left = pigeonVar_list[1] as Double - val bottom = pigeonVar_list[2] as Double - val right = pigeonVar_list[3] as Double - return MbxEdgeInsets(top, left, bottom, right) - } - } - fun toList(): List { - return listOf( - top, - left, - bottom, - right, - ) - } - override fun equals(other: Any?): Boolean { - if (other !is MbxEdgeInsets) { - return false - } - if (this === other) { - return true - } - return top == other.top && - left == other.left && - bottom == other.bottom && - right == other.right - } - - override fun hashCode(): Int = toList().hashCode() -} - -/** - * Various options for describing the viewpoint of a camera. All fields are - * optional. - * - * Anchor and center points are mutually exclusive, with preference for the - * center point when both are set. - * - * Generated class from Pigeon that represents data sent in messages. - */ -data class CameraOptions( - /** Coordinate at the center of the camera. */ - val center: Point? = null, - /** - * Padding around the interior of the view that affects the frame of - * reference for `center`. - */ - val padding: MbxEdgeInsets? = null, - /** - * Point of reference for `zoom` and `angle`, assuming an origin at the - * top-left corner of the view. - */ - val anchor: ScreenCoordinate? = null, - /** - * Zero-based zoom level. Constrained to the minimum and maximum zoom - * levels. - */ - val zoom: Double? = null, - /** Bearing, measured in degrees from true north. Wrapped to [0, 360). */ - val bearing: Double? = null, - /** Pitch toward the horizon measured in degrees. */ - val pitch: Double? = null -) { - companion object { - fun fromList(pigeonVar_list: List): CameraOptions { - val center = pigeonVar_list[0] as Point? - val padding = pigeonVar_list[1] as MbxEdgeInsets? - val anchor = pigeonVar_list[2] as ScreenCoordinate? - val zoom = pigeonVar_list[3] as Double? - val bearing = pigeonVar_list[4] as Double? - val pitch = pigeonVar_list[5] as Double? - return CameraOptions(center, padding, anchor, zoom, bearing, pitch) - } - } - fun toList(): List { - return listOf( - center, - padding, - anchor, - zoom, - bearing, - pitch, - ) - } - override fun equals(other: Any?): Boolean { - if (other !is CameraOptions) { - return false - } - if (this === other) { - return true - } - return center == other.center && - padding == other.padding && - anchor == other.anchor && - zoom == other.zoom && - bearing == other.bearing && - pitch == other.pitch - } - - override fun hashCode(): Int = toList().hashCode() -} - -/** - * Describes the viewpoint of a camera. - * - * Generated class from Pigeon that represents data sent in messages. - */ -data class CameraState( - /** Coordinate at the center of the camera. */ - val center: Point, - /** - * Padding around the interior of the view that affects the frame of - * reference for `center`. - */ - val padding: MbxEdgeInsets, - /** - * Zero-based zoom level. Constrained to the minimum and maximum zoom - * levels. - */ - val zoom: Double, - /** Bearing, measured in degrees from true north. Wrapped to [0, 360). */ - val bearing: Double, - /** Pitch toward the horizon measured in degrees. */ - val pitch: Double -) { - companion object { - fun fromList(pigeonVar_list: List): CameraState { - val center = pigeonVar_list[0] as Point - val padding = pigeonVar_list[1] as MbxEdgeInsets - val zoom = pigeonVar_list[2] as Double - val bearing = pigeonVar_list[3] as Double - val pitch = pigeonVar_list[4] as Double - return CameraState(center, padding, zoom, bearing, pitch) - } - } - fun toList(): List { - return listOf( - center, - padding, - zoom, - bearing, - pitch, - ) - } - override fun equals(other: Any?): Boolean { - if (other !is CameraState) { - return false - } - if (this === other) { - return true - } - return center == other.center && - padding == other.padding && - zoom == other.zoom && - bearing == other.bearing && - pitch == other.pitch - } - - override fun hashCode(): Int = toList().hashCode() -} - /** * Holds options to be used for setting `camera bounds`. * @@ -1269,45 +1075,6 @@ data class MapOptions( override fun hashCode(): Int = toList().hashCode() } -/** - * Describes the coordinate on the screen, measured from top to bottom and from left to right. - * Note: the `map` uses screen coordinate units measured in `logical pixels`. - * - * Generated class from Pigeon that represents data sent in messages. - */ -data class ScreenCoordinate( - /** A value representing the x position of this coordinate. */ - val x: Double, - /** A value representing the y position of this coordinate. */ - val y: Double -) { - companion object { - fun fromList(pigeonVar_list: List): ScreenCoordinate { - val x = pigeonVar_list[0] as Double - val y = pigeonVar_list[1] as Double - return ScreenCoordinate(x, y) - } - } - fun toList(): List { - return listOf( - x, - y, - ) - } - override fun equals(other: Any?): Boolean { - if (other !is ScreenCoordinate) { - return false - } - if (this === other) { - return true - } - return x == other.x && - y == other.y - } - - override fun hashCode(): Int = toList().hashCode() -} - /** * Describes the coordinate box on the screen, measured in `logical pixels` * from top to bottom and from left to right. @@ -2890,17 +2657,17 @@ private open class MapInterfacesPigeonCodec : StandardMessageCodec() { } 160.toByte() -> { return (readValue(buffer) as? List)?.let { - MbxEdgeInsetsDecoder.fromList(it) + MbxEdgeInsets.fromList(it) } } 161.toByte() -> { return (readValue(buffer) as? List)?.let { - CameraOptionsDecoder.fromList(it) + CameraOptions.fromList(it) } } 162.toByte() -> { return (readValue(buffer) as? List)?.let { - CameraStateDecoder.fromList(it) + CameraState.fromList(it) } } 163.toByte() -> { @@ -2945,7 +2712,7 @@ private open class MapInterfacesPigeonCodec : StandardMessageCodec() { } 171.toByte() -> { return (readValue(buffer) as? List)?.let { - ScreenCoordinateDecoder.fromList(it) + ScreenCoordinate.fromList(it) } } 172.toByte() -> { diff --git a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt new file mode 100644 index 000000000..d400f0c91 --- /dev/null +++ b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt @@ -0,0 +1,239 @@ +// Autogenerated from Pigeon (v25.2.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") + +package com.mapbox.maps.mapbox_maps.pigeons + +import com.mapbox.geojson.Point +import com.mapbox.maps.mapbox_maps.mapping.turf.* + +/** + * Error class for passing custom error details to Flutter via a thrown PlatformException. + * @property code The error code. + * @property message The error message. + * @property details The error details. Must be a datatype supported by the api codec. + */ +class FlutterError( + val code: String, + override val message: String? = null, + val details: Any? = null +) : Throwable() + +/** + * Describes the coordinate on the screen, measured from top to bottom and from left to right. + * Note: the `map` uses screen coordinate units measured in `logical pixels`. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class ScreenCoordinate( + /** A value representing the x position of this coordinate. */ + val x: Double, + /** A value representing the y position of this coordinate. */ + val y: Double +) { + companion object { + fun fromList(pigeonVar_list: List): ScreenCoordinate { + val x = pigeonVar_list[0] as Double + val y = pigeonVar_list[1] as Double + return ScreenCoordinate(x, y) + } + } + fun toList(): List { + return listOf( + x, + y, + ) + } + override fun equals(other: Any?): Boolean { + if (other !is ScreenCoordinate) { + return false + } + if (this === other) { + return true + } + return x == other.x && + y == other.y + } + + override fun hashCode(): Int = toList().hashCode() +} + +/** + * The distance on each side between rectangles, when one is contained into other. + * + * All fields' values are in `logical pixel` units. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class MbxEdgeInsets( + /** Padding from the top. */ + val top: Double, + /** Padding from the left. */ + val left: Double, + /** Padding from the bottom. */ + val bottom: Double, + /** Padding from the right. */ + val right: Double +) { + companion object { + fun fromList(pigeonVar_list: List): MbxEdgeInsets { + val top = pigeonVar_list[0] as Double + val left = pigeonVar_list[1] as Double + val bottom = pigeonVar_list[2] as Double + val right = pigeonVar_list[3] as Double + return MbxEdgeInsets(top, left, bottom, right) + } + } + fun toList(): List { + return listOf( + top, + left, + bottom, + right, + ) + } + override fun equals(other: Any?): Boolean { + if (other !is MbxEdgeInsets) { + return false + } + if (this === other) { + return true + } + return top == other.top && + left == other.left && + bottom == other.bottom && + right == other.right + } + + override fun hashCode(): Int = toList().hashCode() +} + +/** + * Various options for describing the viewpoint of a camera. All fields are + * optional. + * + * Anchor and center points are mutually exclusive, with preference for the + * center point when both are set. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class CameraOptions( + /** Coordinate at the center of the camera. */ + val center: Point? = null, + /** + * Padding around the interior of the view that affects the frame of + * reference for `center`. + */ + val padding: MbxEdgeInsets? = null, + /** + * Point of reference for `zoom` and `angle`, assuming an origin at the + * top-left corner of the view. + */ + val anchor: ScreenCoordinate? = null, + /** + * Zero-based zoom level. Constrained to the minimum and maximum zoom + * levels. + */ + val zoom: Double? = null, + /** Bearing, measured in degrees from true north. Wrapped to [0, 360). */ + val bearing: Double? = null, + /** Pitch toward the horizon measured in degrees. */ + val pitch: Double? = null +) { + companion object { + fun fromList(pigeonVar_list: List): CameraOptions { + val center = pigeonVar_list[0] as Point? + val padding = pigeonVar_list[1] as MbxEdgeInsets? + val anchor = pigeonVar_list[2] as ScreenCoordinate? + val zoom = pigeonVar_list[3] as Double? + val bearing = pigeonVar_list[4] as Double? + val pitch = pigeonVar_list[5] as Double? + return CameraOptions(center, padding, anchor, zoom, bearing, pitch) + } + } + fun toList(): List { + return listOf( + center, + padding, + anchor, + zoom, + bearing, + pitch, + ) + } + override fun equals(other: Any?): Boolean { + if (other !is CameraOptions) { + return false + } + if (this === other) { + return true + } + return center == other.center && + padding == other.padding && + anchor == other.anchor && + zoom == other.zoom && + bearing == other.bearing && + pitch == other.pitch + } + + override fun hashCode(): Int = toList().hashCode() +} + +/** + * Describes the viewpoint of a camera. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class CameraState( + /** Coordinate at the center of the camera. */ + val center: Point, + /** + * Padding around the interior of the view that affects the frame of + * reference for `center`. + */ + val padding: MbxEdgeInsets, + /** + * Zero-based zoom level. Constrained to the minimum and maximum zoom + * levels. + */ + val zoom: Double, + /** Bearing, measured in degrees from true north. Wrapped to [0, 360). */ + val bearing: Double, + /** Pitch toward the horizon measured in degrees. */ + val pitch: Double +) { + companion object { + fun fromList(pigeonVar_list: List): CameraState { + val center = pigeonVar_list[0] as Point + val padding = pigeonVar_list[1] as MbxEdgeInsets + val zoom = pigeonVar_list[2] as Double + val bearing = pigeonVar_list[3] as Double + val pitch = pigeonVar_list[4] as Double + return CameraState(center, padding, zoom, bearing, pitch) + } + } + fun toList(): List { + return listOf( + center, + padding, + zoom, + bearing, + pitch, + ) + } + override fun equals(other: Any?): Boolean { + if (other !is CameraState) { + return false + } + if (this === other) { + return true + } + return center == other.center && + padding == other.padding && + zoom == other.zoom && + bearing == other.bearing && + pitch == other.pitch + } + + override fun hashCode(): Int = toList().hashCode() +} \ No newline at end of file diff --git a/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart index f05f01fa2..b1ba97c0a 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart @@ -3,6 +3,9 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show MbxEdgeInsets, CameraOptions, ScreenCoordinate; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart index 355c08f34..01170fdf2 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart @@ -1,6 +1,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show MbxEdgeInsets, CameraOptions, ScreenCoordinate; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart b/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart index d3c10abf2..e4c79b55a 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; class Events { var onMapIdle = Completer(); diff --git a/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart index 8b9561862..a74926012 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart @@ -3,6 +3,9 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show ScreenCoordinate; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart index 1b3c2da36..0f6f18e6f 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart @@ -3,6 +3,8 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, ScreenCoordinate; import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart index ec0c9c0ee..a6152108d 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart @@ -5,6 +5,9 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, ScreenCoordinate; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/snapshotter/snapshotter_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/snapshotter/snapshotter_test.dart index 3e2fc33f4..8cfde171e 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/snapshotter/snapshotter_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/snapshotter/snapshotter_test.dart @@ -5,6 +5,8 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import '../empty_map_widget.dart' as app; void main() { @@ -96,7 +98,7 @@ void main() { expect(bounds, isNotNull); final camera = await snapshotter.camera( - coordinates: [cameraOptions.center!], + coordinates: [Point(coordinates: cameraState.center.coordinates)], bearing: cameraOptions.bearing, pitch: cameraOptions.pitch, ); diff --git a/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart index 14ffc80a5..457b3e1b5 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart @@ -3,6 +3,8 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart b/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart index 41cc8f5e0..bc8f256c5 100644 --- a/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart @@ -9,6 +9,8 @@ import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'package:mapbox_maps_example/main.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:geolocator/geolocator.dart' show Geolocator; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show MbxEdgeInsets, CameraOptions, Point; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/animation_example.dart b/mapbox_maps_flutter_mobile/example/lib/animation_example.dart index a04e6ac0b..89b498f04 100644 --- a/mapbox_maps_flutter_mobile/example/lib/animation_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/animation_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, ScreenCoordinate; import 'example.dart'; class AnimationExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/camera_example.dart b/mapbox_maps_flutter_mobile/example/lib/camera_example.dart index d978e0a25..3362678ad 100644 --- a/mapbox_maps_flutter_mobile/example/lib/camera_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/camera_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show MbxEdgeInsets, CameraOptions, ScreenCoordinate; import 'example.dart'; class CameraExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart index 9a8b6eb2e..24411b508 100644 --- a/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart' hide Visibility; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; class CircleAnnotationExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart b/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart index 2335f39c8..c8b0cc054 100644 --- a/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, ScreenCoordinate; import 'example.dart'; class StyleClustersExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart b/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart index a2eb33cd6..d901e1fcc 100644 --- a/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart @@ -4,6 +4,8 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_example/example.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; class EditPolygonExample extends StatefulWidget implements Example { @override diff --git a/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart b/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart index a09176fa6..a5ff1c3e5 100644 --- a/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, CameraState; import 'example.dart'; class FullMapExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart b/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart index 8155befca..906881fe1 100644 --- a/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; - +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; class DrawGeoJsonLineExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart b/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart index 345592f21..5e08d78ab 100644 --- a/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart @@ -3,6 +3,8 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart b/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart index 824c3c939..a615482e9 100644 --- a/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart @@ -3,6 +3,8 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show ScreenCoordinate; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart b/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart index 05b9162f1..5172d7f7e 100644 --- a/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart @@ -2,6 +2,9 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; + import 'example.dart'; class ModelLayerExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart b/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart index 6f9ad1443..f4de9afb2 100644 --- a/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart @@ -2,6 +2,9 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; + import 'example.dart'; class ModelLayerInteractionsExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart b/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart index 7500752b0..b9861abd9 100644 --- a/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; import 'utils.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart b/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart index 9ae1be37f..a0f373628 100644 --- a/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart index a8afb29b0..90667bef8 100644 --- a/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'package:mapbox_maps_example/utils.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart index c66efbcef..6ec557ee3 100644 --- a/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart index 3c7682fe7..194114989 100644 --- a/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_example/utils.dart'; +import 'utils.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/spinning_globe_example.dart b/mapbox_maps_flutter_mobile/example/lib/spinning_globe_example.dart index 9f187c4eb..2f472be3c 100644 --- a/mapbox_maps_flutter_mobile/example/lib/spinning_globe_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/spinning_globe_example.dart @@ -2,8 +2,10 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:mapbox_maps_example/example.dart'; +import 'example.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions, CameraState; class SpinningGlobeExample extends StatefulWidget implements Example { @override diff --git a/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart b/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart index ae8ad4aa4..7131096a5 100644 --- a/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart @@ -4,6 +4,9 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'example.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; + class StandardStyleImportExample extends StatefulWidget implements Example { @override final Widget leading = const Icon(Icons.touch_app); diff --git a/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart b/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart index b9aa7d884..1760ec1b1 100644 --- a/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart @@ -1,6 +1,9 @@ import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; + import 'example.dart'; class StandardStyleInteractionsExample extends StatefulWidget diff --git a/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart b/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart index dfb0f4ccd..32930de35 100644 --- a/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; - +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; class TileJsonExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart b/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart index 28ae41bc8..ae4939bd5 100644 --- a/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart' hide Visibility; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart b/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart index 0e784f9b9..32fc32c4b 100644 --- a/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:mapbox_maps_example/example.dart'; +import 'example.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; class TrafficRouteLineExample extends StatefulWidget implements Example { @override diff --git a/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart b/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart index c0be7a3df..ccbe183f9 100644 --- a/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' + show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift index 84b296ade..977fdf67b 100644 --- a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift +++ b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/CircleAnnotationMessenger.swift @@ -10,7 +10,7 @@ import Foundation #else #error("Unsupported platform.") #endif -import struct Turf.Point; +import struct Turf.Point /// Error class for passing custom error details to Dart side. final class CircleAnnotationMessengerError: Error { diff --git a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/MapInterfaces.swift b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/MapInterfaces.swift index 1ffc51221..d192ba28b 100644 --- a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/MapInterfaces.swift +++ b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/MapInterfaces.swift @@ -482,146 +482,6 @@ struct TileCoverOptions { } } -/// The distance on each side between rectangles, when one is contained into other. -/// -/// All fields' values are in `logical pixel` units. -/// -/// Generated class from Pigeon that represents data sent in messages. -struct MbxEdgeInsets { - /// Padding from the top. - var top: Double - /// Padding from the left. - var left: Double - /// Padding from the bottom. - var bottom: Double - /// Padding from the right. - var right: Double - - - // swift-format-ignore: AlwaysUseLowerCamelCase - static func fromList(_ pigeonVar_list: [Any?]) -> MbxEdgeInsets? { - let top = pigeonVar_list[0] as! Double - let left = pigeonVar_list[1] as! Double - let bottom = pigeonVar_list[2] as! Double - let right = pigeonVar_list[3] as! Double - - return MbxEdgeInsets( - top: top, - left: left, - bottom: bottom, - right: right - ) - } - func toList() -> [Any?] { - return [ - top, - left, - bottom, - right, - ] - } -} - -/// Various options for describing the viewpoint of a camera. All fields are -/// optional. -/// -/// Anchor and center points are mutually exclusive, with preference for the -/// center point when both are set. -/// -/// Generated class from Pigeon that represents data sent in messages. -struct CameraOptions { - /// Coordinate at the center of the camera. - var center: Point? = nil - /// Padding around the interior of the view that affects the frame of - /// reference for `center`. - var padding: MbxEdgeInsets? = nil - /// Point of reference for `zoom` and `angle`, assuming an origin at the - /// top-left corner of the view. - var anchor: ScreenCoordinate? = nil - /// Zero-based zoom level. Constrained to the minimum and maximum zoom - /// levels. - var zoom: Double? = nil - /// Bearing, measured in degrees from true north. Wrapped to [0, 360). - var bearing: Double? = nil - /// Pitch toward the horizon measured in degrees. - var pitch: Double? = nil - - - // swift-format-ignore: AlwaysUseLowerCamelCase - static func fromList(_ pigeonVar_list: [Any?]) -> CameraOptions? { - let center: Point? = nilOrValue(pigeonVar_list[0]) - let padding: MbxEdgeInsets? = nilOrValue(pigeonVar_list[1]) - let anchor: ScreenCoordinate? = nilOrValue(pigeonVar_list[2]) - let zoom: Double? = nilOrValue(pigeonVar_list[3]) - let bearing: Double? = nilOrValue(pigeonVar_list[4]) - let pitch: Double? = nilOrValue(pigeonVar_list[5]) - - return CameraOptions( - center: center, - padding: padding, - anchor: anchor, - zoom: zoom, - bearing: bearing, - pitch: pitch - ) - } - func toList() -> [Any?] { - return [ - center, - padding, - anchor, - zoom, - bearing, - pitch, - ] - } -} - -/// Describes the viewpoint of a camera. -/// -/// Generated class from Pigeon that represents data sent in messages. -struct CameraState { - /// Coordinate at the center of the camera. - var center: Point - /// Padding around the interior of the view that affects the frame of - /// reference for `center`. - var padding: MbxEdgeInsets - /// Zero-based zoom level. Constrained to the minimum and maximum zoom - /// levels. - var zoom: Double - /// Bearing, measured in degrees from true north. Wrapped to [0, 360). - var bearing: Double - /// Pitch toward the horizon measured in degrees. - var pitch: Double - - - // swift-format-ignore: AlwaysUseLowerCamelCase - static func fromList(_ pigeonVar_list: [Any?]) -> CameraState? { - let center = pigeonVar_list[0] as! Point - let padding = pigeonVar_list[1] as! MbxEdgeInsets - let zoom = pigeonVar_list[2] as! Double - let bearing = pigeonVar_list[3] as! Double - let pitch = pigeonVar_list[4] as! Double - - return CameraState( - center: center, - padding: padding, - zoom: zoom, - bearing: bearing, - pitch: pitch - ) - } - func toList() -> [Any?] { - return [ - center, - padding, - zoom, - bearing, - pitch, - ] - } -} - /// Holds options to be used for setting `camera bounds`. /// /// Generated class from Pigeon that represents data sent in messages. @@ -905,35 +765,6 @@ struct MapOptions { } } -/// Describes the coordinate on the screen, measured from top to bottom and from left to right. -/// Note: the `map` uses screen coordinate units measured in `logical pixels`. -/// -/// Generated class from Pigeon that represents data sent in messages. -struct ScreenCoordinate { - /// A value representing the x position of this coordinate. - var x: Double - /// A value representing the y position of this coordinate. - var y: Double - - - // swift-format-ignore: AlwaysUseLowerCamelCase - static func fromList(_ pigeonVar_list: [Any?]) -> ScreenCoordinate? { - let x = pigeonVar_list[0] as! Double - let y = pigeonVar_list[1] as! Double - - return ScreenCoordinate( - x: x, - y: y - ) - } - func toList() -> [Any?] { - return [ - x, - y, - ] - } -} - /// Describes the coordinate box on the screen, measured in `logical pixels` /// from top to bottom and from left to right. /// @@ -4965,14 +4796,14 @@ protocol StyleManager { /// @return The `transition options` of the current style in use. func getStyleTransition(completion: @escaping (Result) -> Void) /// Adds new import to current style, loaded from a JSON string. - /// + /// /// @param importId Identifier of import to update. /// @param json The JSON string to be loaded directly as the import. /// @param config A map containing the configuration options of the import. /// @param importPosition The import will be positioned according to the ImportPosition parameters. If not specified, then the import is moved to the top of the import stack. func addStyleImportFromJSON(importId: String, json: String, config: [String: Any]?, importPosition: ImportPosition?) throws /// Adds new import to current style, loaded from an URI. - /// + /// /// @param importId Identifier of import to update. /// @param uri URI of the import. /// @param config A map containing the configuration options of the import. @@ -4981,7 +4812,7 @@ protocol StyleManager { /// Updates an existing import in the style. /// The function replaces the content of the import, with the content loaded from the provided data value. /// The configuration values of the import are merged with the configuration provided in the update. - /// + /// /// @param importId Identifier of import to update. /// @param json The JSON string to be loaded directly as the import. /// @param config A map containing the configuration options of the import. @@ -4989,13 +4820,13 @@ protocol StyleManager { /// Updates an existing import in the style. /// The function replaces the content of the import, with the content loaded from the provided URI. /// The configuration values of the import are merged with the configuration provided in the update. - /// + /// /// @param importId Identifier of import to update. /// @param uri URI of the import. /// @param config A map containing the configuration options of the import. func updateStyleImportWithURI(importId: String, uri: String, config: [String: Any]?) throws /// Moves import to position before another import, specified with `beforeId`. Order of imported styles corresponds to order of their layers. - /// + /// /// @param importId Identifier of import to move. /// @param importPosition The import will be positioned according to the ImportPosition parameters. If not specified, then the import is moved to the top of the import stack. func moveStyleImport(importId: String, importPosition: ImportPosition?) throws @@ -5543,7 +5374,7 @@ class StyleManagerSetup { getStyleTransitionChannel.setMessageHandler(nil) } /// Adds new import to current style, loaded from a JSON string. - /// + /// /// @param importId Identifier of import to update. /// @param json The JSON string to be loaded directly as the import. /// @param config A map containing the configuration options of the import. @@ -5567,7 +5398,7 @@ class StyleManagerSetup { addStyleImportFromJSONChannel.setMessageHandler(nil) } /// Adds new import to current style, loaded from an URI. - /// + /// /// @param importId Identifier of import to update. /// @param uri URI of the import. /// @param config A map containing the configuration options of the import. @@ -5593,7 +5424,7 @@ class StyleManagerSetup { /// Updates an existing import in the style. /// The function replaces the content of the import, with the content loaded from the provided data value. /// The configuration values of the import are merged with the configuration provided in the update. - /// + /// /// @param importId Identifier of import to update. /// @param json The JSON string to be loaded directly as the import. /// @param config A map containing the configuration options of the import. @@ -5617,7 +5448,7 @@ class StyleManagerSetup { /// Updates an existing import in the style. /// The function replaces the content of the import, with the content loaded from the provided URI. /// The configuration values of the import are merged with the configuration provided in the update. - /// + /// /// @param importId Identifier of import to update. /// @param uri URI of the import. /// @param config A map containing the configuration options of the import. @@ -5639,7 +5470,7 @@ class StyleManagerSetup { updateStyleImportWithURIChannel.setMessageHandler(nil) } /// Moves import to position before another import, specified with `beforeId`. Order of imported styles corresponds to order of their layers. - /// + /// /// @param importId Identifier of import to move. /// @param importPosition The import will be positioned according to the ImportPosition parameters. If not specified, then the import is moved to the top of the import stack. let moveStyleImportChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.mapbox_maps_flutter.StyleManager.moveStyleImport\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) diff --git a/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/PlatformInterfaceDataTypes.swift b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/PlatformInterfaceDataTypes.swift new file mode 100644 index 000000000..8524c6b93 --- /dev/null +++ b/mapbox_maps_flutter_mobile/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Generated/PlatformInterfaceDataTypes.swift @@ -0,0 +1,209 @@ +// Autogenerated from Pigeon (v25.2.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +import Foundation + +#if os(iOS) + import Flutter +#elseif os(macOS) + import FlutterMacOS +#else + #error("Unsupported platform.") +#endif +import struct Turf.Point + +/// Error class for passing custom error details to Dart side. +final class PlatformInterfaceDataTypesError: Error { + let code: String + let message: String? + let details: Sendable? + + init(code: String, message: String?, details: Sendable?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "PlatformInterfaceDataTypesError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} + +private func isNullish(_ value: Any?) -> Bool { + return value is NSNull || value == nil +} + +private func nilOrValue(_ value: Any?) -> T? { + if value is NSNull { return nil } + return value as! T? +} + +/// Describes the coordinate on the screen, measured from top to bottom and from left to right. +/// Note: the `map` uses screen coordinate units measured in `logical pixels`. +/// +/// Generated class from Pigeon that represents data sent in messages. +struct ScreenCoordinate { + /// A value representing the x position of this coordinate. + var x: Double + /// A value representing the y position of this coordinate. + var y: Double + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> ScreenCoordinate? { + let x = pigeonVar_list[0] as! Double + let y = pigeonVar_list[1] as! Double + + return ScreenCoordinate( + x: x, + y: y + ) + } + func toList() -> [Any?] { + return [ + x, + y, + ] + } +} + +/// The distance on each side between rectangles, when one is contained into other. +/// +/// All fields' values are in `logical pixel` units. +/// +/// Generated class from Pigeon that represents data sent in messages. +struct MbxEdgeInsets { + /// Padding from the top. + var top: Double + /// Padding from the left. + var left: Double + /// Padding from the bottom. + var bottom: Double + /// Padding from the right. + var right: Double + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> MbxEdgeInsets? { + let top = pigeonVar_list[0] as! Double + let left = pigeonVar_list[1] as! Double + let bottom = pigeonVar_list[2] as! Double + let right = pigeonVar_list[3] as! Double + + return MbxEdgeInsets( + top: top, + left: left, + bottom: bottom, + right: right + ) + } + func toList() -> [Any?] { + return [ + top, + left, + bottom, + right, + ] + } +} + +/// Various options for describing the viewpoint of a camera. All fields are +/// optional. +/// +/// Anchor and center points are mutually exclusive, with preference for the +/// center point when both are set. +/// +/// Generated class from Pigeon that represents data sent in messages. +struct CameraOptions { + /// Coordinate at the center of the camera. + var center: Point? = nil + /// Padding around the interior of the view that affects the frame of + /// reference for `center`. + var padding: MbxEdgeInsets? = nil + /// Point of reference for `zoom` and `angle`, assuming an origin at the + /// top-left corner of the view. + var anchor: ScreenCoordinate? = nil + /// Zero-based zoom level. Constrained to the minimum and maximum zoom + /// levels. + var zoom: Double? = nil + /// Bearing, measured in degrees from true north. Wrapped to [0, 360). + var bearing: Double? = nil + /// Pitch toward the horizon measured in degrees. + var pitch: Double? = nil + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> CameraOptions? { + let center: Point? = nilOrValue(pigeonVar_list[0]) + let padding: MbxEdgeInsets? = nilOrValue(pigeonVar_list[1]) + let anchor: ScreenCoordinate? = nilOrValue(pigeonVar_list[2]) + let zoom: Double? = nilOrValue(pigeonVar_list[3]) + let bearing: Double? = nilOrValue(pigeonVar_list[4]) + let pitch: Double? = nilOrValue(pigeonVar_list[5]) + + return CameraOptions( + center: center, + padding: padding, + anchor: anchor, + zoom: zoom, + bearing: bearing, + pitch: pitch + ) + } + func toList() -> [Any?] { + return [ + center, + padding, + anchor, + zoom, + bearing, + pitch, + ] + } +} + +/// Describes the viewpoint of a camera. +/// +/// Generated class from Pigeon that represents data sent in messages. +struct CameraState { + /// Coordinate at the center of the camera. + var center: Point + /// Padding around the interior of the view that affects the frame of + /// reference for `center`. + var padding: MbxEdgeInsets + /// Zero-based zoom level. Constrained to the minimum and maximum zoom + /// levels. + var zoom: Double + /// Bearing, measured in degrees from true north. Wrapped to [0, 360). + var bearing: Double + /// Pitch toward the horizon measured in degrees. + var pitch: Double + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> CameraState? { + let center = pigeonVar_list[0] as! Point + let padding = pigeonVar_list[1] as! MbxEdgeInsets + let zoom = pigeonVar_list[2] as! Double + let bearing = pigeonVar_list[3] as! Double + let pitch = pigeonVar_list[4] as! Double + + return CameraState( + center: center, + padding: padding, + zoom: zoom, + bearing: bearing, + pitch: pitch + ) + } + func toList() -> [Any?] { + return [ + center, + padding, + zoom, + bearing, + pitch, + ] + } +} diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart index 1ca57a7dd..7cb6a27e8 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart @@ -458,6 +458,7 @@ class MapboxMap extends ChangeNotifier { options); /// Queries the map for rendered features with one typed featureset. + @experimental Future> queryRenderedFeaturesForFeatureset( {required FeaturesetDescriptor featureset, RenderedQueryGeometry? geometry, @@ -515,6 +516,7 @@ class MapboxMap extends ChangeNotifier { /// Update the state map of a feature within a featureset. /// Update entries in the state map of a given feature within a style source. Only entries listed in the state map /// will be updated. An entry in the feature state map that is not listed in `state` will retain its previous value. + @experimental Future setFeatureStateForFeaturesetDescriptor( FeaturesetDescriptor featureset, FeaturesetFeatureId featureId, @@ -526,6 +528,7 @@ class MapboxMap extends ChangeNotifier { /// /// The feature should have a non-nil ``FeaturesetFeatureType/id``. Otherwise, /// the operation will be no-op and callback will receive an error. + @experimental Future setFeatureStateForFeaturesetFeature( FeaturesetFeature feature, FeatureState state) => _mapInterface.setFeatureStateForFeaturesetFeature(feature, state.map); @@ -539,12 +542,14 @@ class MapboxMap extends ChangeNotifier { _mapInterface.getFeatureState(sourceId, sourceLayerId, featureId); /// Get the state map of a feature within a style source. + @experimental Future> getFeatureStateForFeaturesetDescriptor( FeaturesetDescriptor featureset, FeaturesetFeatureId featureId) => _mapInterface.getFeatureStateForFeaturesetDescriptor( featureset, featureId); /// Get the state map of a feature within a style source. + @experimental Future> getFeatureStateForFeaturesetFeature( FeaturesetFeature feature) => _mapInterface.getFeatureStateForFeaturesetFeature(feature); @@ -563,6 +568,7 @@ class MapboxMap extends ChangeNotifier { /// Removes entries from a feature state object of a feature in the specified featureset. /// Remove a specified property or all property from a feature's state object, depending on the value of `stateKey`. + @experimental Future removeFeatureStateForFeaturesetDescriptor( {required FeaturesetDescriptor featureset, required FeaturesetFeatureId featureId, @@ -572,6 +578,7 @@ class MapboxMap extends ChangeNotifier { /// Removes entries from a specified Feature. /// Remove a specified property or all property from a feature's state object, depending on the value of `stateKey`. + @experimental Future removeFeatureStateForFeaturesetFeature( {required FeaturesetFeature feature, String? stateKey}) => _mapInterface.removeFeatureStateForFeaturesetFeature(feature, stateKey); @@ -580,16 +587,19 @@ class MapboxMap extends ChangeNotifier { /// /// Note that updates to feature state are asynchronous, so changes made by this method might not be /// immediately visible using ``MapboxMap/getFeatureState(_:callback:)``. + @experimental Future resetFeatureStatesForFeatureset( FeaturesetDescriptor featureset) => _mapInterface.resetFeatureStatesForFeatureset(featureset); /// References for all interactions added to the map. + @experimental final _InteractionsMap _interactionsMap = _InteractionsMap(interactions: {}); /// Add an interaction to the map /// An identifier can be provided, which you can use to remove /// the interaction with `.removeInteraction(interactionID)` + @experimental void addInteraction>( TypedInteraction interaction, {String? interactionID}) { @@ -606,6 +616,7 @@ class MapboxMap extends ChangeNotifier { /// Remove an interaction from the map with the given interactionID /// that was passed with `.addInteraction(interaction, interactionID)` + @experimental void removeInteraction(String interactionID) { _interactionsMap.interactions.remove(interactionID); _mapboxMapsPlatform.removeInteractionsListeners(interactionID); diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart index d25115ea3..10f645f39 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart @@ -4,8 +4,12 @@ base class MapboxMapsFlutterMobile extends MapboxMapsFlutterPlatform { late final MapboxMap _mapboxMap; @override - Widget buildView() { + Widget buildView({CameraOptions? cameraOptions}) { + if (cameraOptions?.center != null) { + cameraOptions?.center = Point._from(cameraOptions.center!); + } return MapWidget( + cameraOptions: cameraOptions, onMapCreated: (MapboxMap mapboxMap) { _mapboxMap = mapboxMap; }, diff --git a/mapbox_maps_flutter_mobile/lib/src/pigeons/map_interfaces.dart b/mapbox_maps_flutter_mobile/lib/src/pigeons/map_interfaces.dart index 8ae8b74c2..08c0919ce 100644 --- a/mapbox_maps_flutter_mobile/lib/src/pigeons/map_interfaces.dart +++ b/mapbox_maps_flutter_mobile/lib/src/pigeons/map_interfaces.dart @@ -561,230 +561,6 @@ class TileCoverOptions { int get hashCode => Object.hashAll(_toList()); } -/// The distance on each side between rectangles, when one is contained into other. -/// -/// All fields' values are in `logical pixel` units. -class MbxEdgeInsets { - MbxEdgeInsets({ - required this.top, - required this.left, - required this.bottom, - required this.right, - }); - - /// Padding from the top. - double top; - - /// Padding from the left. - double left; - - /// Padding from the bottom. - double bottom; - - /// Padding from the right. - double right; - - List _toList() { - return [ - top, - left, - bottom, - right, - ]; - } - - Object encode() { - return _toList(); - } - - static MbxEdgeInsets decode(Object result) { - result as List; - return MbxEdgeInsets( - top: result[0]! as double, - left: result[1]! as double, - bottom: result[2]! as double, - right: result[3]! as double, - ); - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(Object other) { - if (other is! MbxEdgeInsets || other.runtimeType != runtimeType) { - return false; - } - if (identical(this, other)) { - return true; - } - return top == other.top && - left == other.left && - bottom == other.bottom && - right == other.right; - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); -} - -/// Various options for describing the viewpoint of a camera. All fields are -/// optional. -/// -/// Anchor and center points are mutually exclusive, with preference for the -/// center point when both are set. -class CameraOptions { - CameraOptions({ - this.center, - this.padding, - this.anchor, - this.zoom, - this.bearing, - this.pitch, - }); - - /// Coordinate at the center of the camera. - Point? center; - - /// Padding around the interior of the view that affects the frame of - /// reference for `center`. - MbxEdgeInsets? padding; - - /// Point of reference for `zoom` and `angle`, assuming an origin at the - /// top-left corner of the view. - ScreenCoordinate? anchor; - - /// Zero-based zoom level. Constrained to the minimum and maximum zoom - /// levels. - double? zoom; - - /// Bearing, measured in degrees from true north. Wrapped to [0, 360). - double? bearing; - - /// Pitch toward the horizon measured in degrees. - double? pitch; - - List _toList() { - return [ - center, - padding, - anchor, - zoom, - bearing, - pitch, - ]; - } - - Object encode() { - return _toList(); - } - - static CameraOptions decode(Object result) { - result as List; - return CameraOptions( - center: result[0] as Point?, - padding: result[1] as MbxEdgeInsets?, - anchor: result[2] as ScreenCoordinate?, - zoom: result[3] as double?, - bearing: result[4] as double?, - pitch: result[5] as double?, - ); - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(Object other) { - if (other is! CameraOptions || other.runtimeType != runtimeType) { - return false; - } - if (identical(this, other)) { - return true; - } - return center == other.center && - padding == other.padding && - anchor == other.anchor && - zoom == other.zoom && - bearing == other.bearing && - pitch == other.pitch; - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); -} - -/// Describes the viewpoint of a camera. -class CameraState { - CameraState({ - required this.center, - required this.padding, - required this.zoom, - required this.bearing, - required this.pitch, - }); - - /// Coordinate at the center of the camera. - Point center; - - /// Padding around the interior of the view that affects the frame of - /// reference for `center`. - MbxEdgeInsets padding; - - /// Zero-based zoom level. Constrained to the minimum and maximum zoom - /// levels. - double zoom; - - /// Bearing, measured in degrees from true north. Wrapped to [0, 360). - double bearing; - - /// Pitch toward the horizon measured in degrees. - double pitch; - - List _toList() { - return [ - center, - padding, - zoom, - bearing, - pitch, - ]; - } - - Object encode() { - return _toList(); - } - - static CameraState decode(Object result) { - result as List; - return CameraState( - center: result[0]! as Point, - padding: result[1]! as MbxEdgeInsets, - zoom: result[2]! as double, - bearing: result[3]! as double, - pitch: result[4]! as double, - ); - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(Object other) { - if (other is! CameraState || other.runtimeType != runtimeType) { - return false; - } - if (identical(this, other)) { - return true; - } - return center == other.center && - padding == other.padding && - zoom == other.zoom && - bearing == other.bearing && - pitch == other.pitch; - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); -} - /// Holds options to be used for setting `camera bounds`. class CameraBoundsOptions { CameraBoundsOptions({ @@ -1266,56 +1042,6 @@ class MapOptions { int get hashCode => Object.hashAll(_toList()); } -/// Describes the coordinate on the screen, measured from top to bottom and from left to right. -/// Note: the `map` uses screen coordinate units measured in `logical pixels`. -class ScreenCoordinate { - ScreenCoordinate({ - required this.x, - required this.y, - }); - - /// A value representing the x position of this coordinate. - double x; - - /// A value representing the y position of this coordinate. - double y; - - List _toList() { - return [ - x, - y, - ]; - } - - Object encode() { - return _toList(); - } - - static ScreenCoordinate decode(Object result) { - result as List; - return ScreenCoordinate( - x: result[0]! as double, - y: result[1]! as double, - ); - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(Object other) { - if (other is! ScreenCoordinate || other.runtimeType != runtimeType) { - return false; - } - if (identical(this, other)) { - return true; - } - return x == other.x && y == other.y; - } - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); -} - /// Describes the coordinate box on the screen, measured in `logical pixels` /// from top to bottom and from left to right. class ScreenBox { diff --git a/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart b/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart index be76d48ba..70117c5b8 100644 --- a/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart +++ b/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart @@ -8,6 +8,10 @@ final class Point extends turf.Point { return Point(bbox: turfPoint.bbox, coordinates: turfPoint.coordinates); } + factory Point._from(turf.Point point) { + return Point(bbox: point.bbox, coordinates: point.coordinates); + } + static Point decode(Object result) { var map = (result is List) ? result.first : result; return Point.fromJson((map as Map).cast()); diff --git a/mapbox_maps_flutter_mobile/pubspec.yaml b/mapbox_maps_flutter_mobile/pubspec.yaml index fb45eebd6..2c04af077 100644 --- a/mapbox_maps_flutter_mobile/pubspec.yaml +++ b/mapbox_maps_flutter_mobile/pubspec.yaml @@ -13,7 +13,6 @@ dependencies: flutter: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.5 - turf: ^0.0.8 typed_data: ^1.3.0 meta: ^1.9.1 mapbox_maps_flutter_interface: any diff --git a/mapbox_maps_flutter_v3/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/mapbox_maps_flutter_v3/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f0bf926d2..a37adb51b 100644 --- a/mapbox_maps_flutter_v3/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/mapbox_maps_flutter_v3/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-common-ios.git", "state" : { - "revision" : "6efcdd6ca3ded3647f3ff897845c679d52dd625a", - "version" : "24.12.0-rc.1" + "revision" : "316a4f97bcf45aaae632327b69fac545cc38e42f", + "version" : "24.12.0" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-core-maps-ios.git", "state" : { - "revision" : "bfb41b136ecd52b45e35fe25b1b4840309a3994d", - "version" : "11.12.0-rc.1" + "revision" : "853cfc3c431d42291e1c4a0d550fc8cf6ea90015", + "version" : "11.12.0" } }, { @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-maps-ios.git", "state" : { - "revision" : "5f46396a6816c6d89a4ca8df39c22db2f9f9e3d2", - "version" : "11.12.0-rc.1" + "revision" : "c141954157c3aaf09bc1bc3d233239666421b96e", + "version" : "11.12.0" } }, { diff --git a/mapbox_maps_flutter_v3/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved b/mapbox_maps_flutter_v3/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved index f0bf926d2..a37adb51b 100644 --- a/mapbox_maps_flutter_v3/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/mapbox_maps_flutter_v3/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-common-ios.git", "state" : { - "revision" : "6efcdd6ca3ded3647f3ff897845c679d52dd625a", - "version" : "24.12.0-rc.1" + "revision" : "316a4f97bcf45aaae632327b69fac545cc38e42f", + "version" : "24.12.0" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-core-maps-ios.git", "state" : { - "revision" : "bfb41b136ecd52b45e35fe25b1b4840309a3994d", - "version" : "11.12.0-rc.1" + "revision" : "853cfc3c431d42291e1c4a0d550fc8cf6ea90015", + "version" : "11.12.0" } }, { @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mapbox/mapbox-maps-ios.git", "state" : { - "revision" : "5f46396a6816c6d89a4ca8df39c22db2f9f9e3d2", - "version" : "11.12.0-rc.1" + "revision" : "c141954157c3aaf09bc1bc3d233239666421b96e", + "version" : "11.12.0" } }, { diff --git a/mapbox_maps_flutter_v3/example/lib/main.dart b/mapbox_maps_flutter_v3/example/lib/main.dart index ae7879e15..e3dcd8777 100644 --- a/mapbox_maps_flutter_v3/example/lib/main.dart +++ b/mapbox_maps_flutter_v3/example/lib/main.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; +import 'utils.dart'; + void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); @@ -29,7 +31,10 @@ class _MyAppState extends State { return MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('Example app')), - body: Center(child: MapWidget()), + body: Center( + child: MapWidget( + cameraOptions: CameraOptions(center: City.helsinki, zoom: 6), + )), ), ); } diff --git a/mapbox_maps_flutter_v3/example/lib/utils.dart b/mapbox_maps_flutter_v3/example/lib/utils.dart new file mode 100644 index 000000000..85b109830 --- /dev/null +++ b/mapbox_maps_flutter_v3/example/lib/utils.dart @@ -0,0 +1,6 @@ +import 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; + +extension City on Point { + static Point get helsinki => + Point(coordinates: Position.of([24.941, 60.173])); +} diff --git a/mapbox_maps_flutter_v3/lib/mapbox_maps_flutter_v3.dart b/mapbox_maps_flutter_v3/lib/mapbox_maps_flutter_v3.dart index f10cc7014..641ee72f2 100644 --- a/mapbox_maps_flutter_v3/lib/mapbox_maps_flutter_v3.dart +++ b/mapbox_maps_flutter_v3/lib/mapbox_maps_flutter_v3.dart @@ -1,9 +1,6 @@ library; -import 'dart:io'; +export 'src/map_widget.dart'; +export 'src/mapbox_options.dart'; -import 'package:flutter/material.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; - -part 'src/map_widget.dart'; -part 'src/mapbox_options.dart'; +export 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; diff --git a/mapbox_maps_flutter_v3/lib/src/map_widget.dart b/mapbox_maps_flutter_v3/lib/src/map_widget.dart index 11fff3b7b..9c98961be 100644 --- a/mapbox_maps_flutter_v3/lib/src/map_widget.dart +++ b/mapbox_maps_flutter_v3/lib/src/map_widget.dart @@ -1,16 +1,17 @@ -part of 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; +import 'package:flutter/widgets.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; class MapWidget extends StatelessWidget { final MapboxMapsFlutterPlatform _platform; + /// The initial Camera options when creating a MapWidget. + final CameraOptions? cameraOptions; + MapWidget({ super.key, this.cameraOptions, }) : _platform = MapboxMapsFlutterPlatform.instance; - /// The initial Camera options when creating a MapWidget. - final CameraOptions? cameraOptions; - @override Widget build(BuildContext context) { return _platform.buildView(cameraOptions: cameraOptions); diff --git a/mapbox_maps_flutter_v3/lib/src/mapbox_options.dart b/mapbox_maps_flutter_v3/lib/src/mapbox_options.dart index bb65344bf..a179cfd34 100644 --- a/mapbox_maps_flutter_v3/lib/src/mapbox_options.dart +++ b/mapbox_maps_flutter_v3/lib/src/mapbox_options.dart @@ -1,4 +1,4 @@ -part of 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; /// A class that provides options and configurations for Mapbox services. /// diff --git a/mapbox_maps_flutter_web/example/pubspec.lock b/mapbox_maps_flutter_web/example/pubspec.lock index e261180dd..d7ec1b519 100644 --- a/mapbox_maps_flutter_web/example/pubspec.lock +++ b/mapbox_maps_flutter_web/example/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" async: dependency: transitive description: @@ -9,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.12.0" + benchmark: + dependency: transitive + description: + name: benchmark + sha256: cb3eeea01e3f054df76ee9775ca680f3afa5f19f39b2bb426ba78ba27654493b + url: "https://pub.dev" + source: hosted + version: "0.3.0" boolean_selector: dependency: transitive description: @@ -49,6 +65,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dart_sort_queue: + dependency: transitive + description: + name: dart_sort_queue + sha256: f3353ba8b4850e072d3368757f62edb79af34a9703c3e3df9c59342721f5f5b1 + url: "https://pub.dev" + source: hosted + version: "0.0.2+3" fake_async: dependency: transitive description: @@ -98,11 +122,27 @@ packages: description: flutter source: sdk version: "0.0.0" + geotypes: + dependency: transitive + description: + name: geotypes + sha256: "5bedf57de92283133dd221e363812ef50eaaba414f0823b1974ef7d84b86991f" + url: "https://pub.dev" + source: hosted + version: "0.0.2" integration_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" leak_tracker: dependency: transitive description: @@ -205,6 +245,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.3" + rbush: + dependency: transitive + description: + name: rbush + sha256: "48b683421b4afb43a642f82c6aa31911e54f3069143d31c7d33cbe329df13403" + url: "https://pub.dev" + source: hosted + version: "1.1.1" sky_engine: dependency: transitive description: flutter @@ -242,6 +290,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" + sweepline_intersections: + dependency: transitive + description: + name: sweepline_intersections + sha256: a665c707200a4f07140a4029b41a7c4883beb3f04322cd8e08ebf650f69e1176 + url: "https://pub.dev" + source: hosted + version: "0.0.4" sync_http: dependency: transitive description: @@ -266,6 +322,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.4" + turf: + dependency: transitive + description: + name: turf + sha256: "75347c45a5c1de805db7cb182286f05a3770e01546626c4dc292709d15cbe436" + url: "https://pub.dev" + source: hosted + version: "0.0.10" + turf_equality: + dependency: transitive + description: + name: turf_equality + sha256: f0f44ffe389547941358e0d3d4a747db2bd56115b32ff1cede5e5bdf3126a3e2 + url: "https://pub.dev" + source: hosted + version: "0.1.0" + turf_pip: + dependency: transitive + description: + name: turf_pip + sha256: ba4fd414baffd5d7b30880658ad6db82461c49ec023f8ffd0c23d398ad8b14be + url: "https://pub.dev" + source: hosted + version: "0.0.2" vector_math: dependency: transitive description: diff --git a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart index aaa8ca4c8..0b603b2a3 100644 --- a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart +++ b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart @@ -18,7 +18,7 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { late HTMLDivElement _mapElement; @override - Widget buildView() { + Widget buildView({CameraOptions? cameraOptions}) { final viewType = 'mapbox-maps-flutter-web/$hashCode'; // Attach the mapDiv to the DOM From d3a0d4fe34f6c86d4e6b31a956e4194ad3c79700 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Thu, 15 May 2025 15:33:07 +0300 Subject: [PATCH 6/9] add tests for camera get/set --- .../lib/mapbox_maps_flutter_interface.dart | 3 +- .../lib/src/callbacks.dart | 2 + .../lib/src/map_interface.dart | 18 +++++ ...apbox_maps_flutter_platform_interface.dart | 5 +- .../lib/src/turf_adapter.dart | 19 ----- .../lib/src/mapbox_map.dart | 12 ++- .../lib/src/mapbox_maps_flutter_mobile.dart | 11 ++- .../example/integration_test/app.dart | 40 ++++++++++ .../example/integration_test/camera_test.dart | 74 +++++++++++++++++++ mapbox_maps_flutter_v3/example/lib/main.dart | 7 ++ .../lib/src/map_widget.dart | 10 ++- .../lib/src/mapbox_maps_flutter_web.dart | 5 +- 12 files changed, 176 insertions(+), 30 deletions(-) create mode 100644 mapbox_maps_flutter_interface/lib/src/map_interface.dart delete mode 100644 mapbox_maps_flutter_interface/lib/src/turf_adapter.dart create mode 100644 mapbox_maps_flutter_v3/example/integration_test/app.dart create mode 100644 mapbox_maps_flutter_v3/example/integration_test/camera_test.dart diff --git a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart index 354b2587e..2bfe0a952 100644 --- a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart +++ b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart @@ -1,9 +1,10 @@ library mapbox_maps_flutter_interface; export 'src/mapbox_maps_flutter_platform_interface.dart'; +export 'src/map_interface.dart'; +export 'src/callbacks.dart'; export 'package:turf/helpers.dart'; import 'package:turf/turf.dart'; part 'src/pigeons/platform_interface_data_types.dart'; -part 'src/turf_adapter.dart'; diff --git a/mapbox_maps_flutter_interface/lib/src/callbacks.dart b/mapbox_maps_flutter_interface/lib/src/callbacks.dart index 8b1378917..988d70abc 100644 --- a/mapbox_maps_flutter_interface/lib/src/callbacks.dart +++ b/mapbox_maps_flutter_interface/lib/src/callbacks.dart @@ -1 +1,3 @@ +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; +typedef OnMapCreated = void Function(MapboxMapInterface mapboxMap); diff --git a/mapbox_maps_flutter_interface/lib/src/map_interface.dart b/mapbox_maps_flutter_interface/lib/src/map_interface.dart new file mode 100644 index 000000000..92c5a6fd8 --- /dev/null +++ b/mapbox_maps_flutter_interface/lib/src/map_interface.dart @@ -0,0 +1,18 @@ +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; + +/// An abstract base class that defines the interface for interacting with a Mapbox map. +/// +/// This interface provides methods for setting the camera options and retrieving the current camera state. +abstract base class MapboxMapInterface { + /// Sets the camera options for the map. + /// + /// [cameraOptions] - The desired camera options to apply to the map. + /// + /// Returns a [Future] that completes when the camera options have been applied. + Future setCamera(CameraOptions cameraOptions); + + /// Retrieves the current state of the camera. + /// + /// Returns a [Future] that completes with the current [CameraState] of the map. + Future getCameraState(); +} diff --git a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart index 89accff0e..e51703531 100644 --- a/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart +++ b/mapbox_maps_flutter_interface/lib/src/mapbox_maps_flutter_platform_interface.dart @@ -40,5 +40,8 @@ abstract base class MapboxMapsFlutterPlatform { /// /// This method is responsible for creating the widget that integrates /// with the underlying platform's view system to render the map. - Widget buildView({CameraOptions? cameraOptions}); + Widget buildView({ + CameraOptions? cameraOptions, + OnMapCreated? onMapCreated, + }); } diff --git a/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart b/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart deleted file mode 100644 index cf78ea479..000000000 --- a/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart +++ /dev/null @@ -1,19 +0,0 @@ -part of 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; - -// final class Point extends turf.Point { -// Point({super.bbox, required super.coordinates}); - -// factory Point.fromJson(Map json) { -// final turfPoint = turf.Point.fromJson(json); -// return Point(bbox: turfPoint.bbox, coordinates: turfPoint.coordinates); -// } - -// static Point decode(Object result) { -// var map = (result is List) ? result.first : result; -// return Point.fromJson((map as Map).cast()); -// } - -// Object encode() { -// return [toJson()]; -// } -// } diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart index 7cb6a27e8..15b1aa805 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart @@ -136,7 +136,7 @@ extension on _MapWidgetDebugOptions { } /// Controller for a single MapboxMap instance running on the host platform. -class MapboxMap extends ChangeNotifier { +final class MapboxMap extends MapboxMapInterface with ChangeNotifier { MapboxMap._({ required _MapboxMapsPlatform mapboxMapsPlatform, this.onMapTapListener, @@ -344,10 +344,16 @@ class MapboxMap extends ChangeNotifier { /// The map will retain its current values for any details not passed via the camera options argument. /// It is not guaranteed that the provided `camera options` will be set, the map may apply constraints resulting in a /// different `camera state`. - Future setCamera(CameraOptions cameraOptions) => - _cameraManager.setCamera(cameraOptions); + @override + Future setCamera(CameraOptions cameraOptions) { + if (cameraOptions.center != null) { + cameraOptions.center = Point._from(cameraOptions.center!); + } + return _cameraManager.setCamera(cameraOptions); + } /// Returns the current `camera state`. + @override Future getCameraState() => _cameraManager.getCameraState(); /// Sets the `camera bounds options` of the map. The map will retain its current values for any diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart index 10f645f39..6b42c0fc7 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart @@ -1,17 +1,20 @@ part of 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; base class MapboxMapsFlutterMobile extends MapboxMapsFlutterPlatform { - late final MapboxMap _mapboxMap; - @override - Widget buildView({CameraOptions? cameraOptions}) { + Widget buildView({ + CameraOptions? cameraOptions, + OnMapCreated? onMapCreated, + }) { if (cameraOptions?.center != null) { cameraOptions?.center = Point._from(cameraOptions.center!); } return MapWidget( cameraOptions: cameraOptions, onMapCreated: (MapboxMap mapboxMap) { - _mapboxMap = mapboxMap; + if (onMapCreated != null) { + onMapCreated(mapboxMap); + } }, ); } diff --git a/mapbox_maps_flutter_v3/example/integration_test/app.dart b/mapbox_maps_flutter_v3/example/integration_test/app.dart new file mode 100644 index 000000000..3a8af8367 --- /dev/null +++ b/mapbox_maps_flutter_v3/example/integration_test/app.dart @@ -0,0 +1,40 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; + +const ACCESS_TOKEN = String.fromEnvironment('ACCESS_TOKEN'); + +Future main( + {double? width, + double? height, + CameraOptions? camera, + Alignment alignment = Alignment.topLeft}) { + final completer = Completer(); + + MapboxOptions.setAccessToken(ACCESS_TOKEN); + + runApp(MaterialApp( + home: Align( + alignment: alignment, + child: SizedBox( + width: width, + height: height, + child: MapWidget( + key: ValueKey("mapWidget"), + cameraOptions: camera, + onMapCreated: (MapboxMap mapboxMap) { + completer.complete(mapboxMap); + }, + ), + ), + ))); + + return completer.future; +} + +void runEmpty() { + MapboxOptions.setAccessToken(ACCESS_TOKEN); + + runApp(MaterialApp()); +} diff --git a/mapbox_maps_flutter_v3/example/integration_test/camera_test.dart b/mapbox_maps_flutter_v3/example/integration_test/camera_test.dart new file mode 100644 index 000000000..b271f25cc --- /dev/null +++ b/mapbox_maps_flutter_v3/example/integration_test/camera_test.dart @@ -0,0 +1,74 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; + +import 'app.dart' as app; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + final initialCamera = CameraOptions( + center: Point(coordinates: Position(0, 0)), + padding: MbxEdgeInsets(top: 10, left: 20, bottom: 30, right: 40), + zoom: 15, + pitch: 60, + bearing: 12, + ); + + group('camera get and set', () { + testWidgets('set camera when creating a map', (WidgetTester tester) async { + final mapFuture = app.main(camera: initialCamera); + await tester.pumpAndSettle(); + final mapboxMap = await mapFuture; + + // Verify that the camera options are set correctly + final camera = await mapboxMap.getCameraState(); + expect(camera.center.coordinates.lng, + closeTo(initialCamera.center!.coordinates.lng, 0.0001)); + expect(camera.center.coordinates.lat, + closeTo(initialCamera.center!.coordinates.lat, 0.0001)); + expect(camera.padding.top, closeTo(initialCamera.padding!.top, 0.0001)); + expect(camera.padding.left, closeTo(initialCamera.padding!.left, 0.0001)); + expect(camera.padding.bottom, + closeTo(initialCamera.padding!.bottom, 0.0001)); + expect( + camera.padding.right, closeTo(initialCamera.padding!.right, 0.0001)); + expect(camera.zoom, closeTo(initialCamera.zoom!, 0.0001)); + expect(camera.pitch, closeTo(initialCamera.pitch!, 0.0001)); + expect(camera.bearing, closeTo(initialCamera.bearing!, 0.0001)); + }); + + testWidgets('set camera after map created', (tester) async { + final mapFuture = app.main(); + await tester.pumpAndSettle(); + final mapboxMap = await mapFuture; + + // Set the camera options + final cameraOptions = CameraOptions( + center: Point(coordinates: Position(1, 1)), + padding: MbxEdgeInsets(top: 10, left: 20, bottom: 30, right: 40), + zoom: 15, + pitch: 60, + bearing: 12, + ); + + await mapboxMap.setCamera(cameraOptions); + await tester.pumpAndSettle(); + + final camera = await mapboxMap.getCameraState(); + expect(camera.center.coordinates.lng, + closeTo(cameraOptions.center!.coordinates.lng, 0.0001)); + expect(camera.center.coordinates.lat, + closeTo(cameraOptions.center!.coordinates.lat, 0.0001)); + expect( + camera.padding.top, closeTo(cameraOptions.padding?.top ?? 0, 0.0001)); + expect(camera.padding.left, closeTo(cameraOptions.padding!.left, 0.0001)); + expect(camera.padding.bottom, + closeTo(cameraOptions.padding!.bottom, 0.0001)); + expect( + camera.padding.right, closeTo(cameraOptions.padding!.right, 0.0001)); + expect(camera.zoom, closeTo(cameraOptions.zoom!, 0.0001)); + expect(camera.pitch, closeTo(cameraOptions.pitch!, 0.0001)); + expect(camera.bearing, closeTo(cameraOptions.bearing!, 0.0001)); + }); + }); +} diff --git a/mapbox_maps_flutter_v3/example/lib/main.dart b/mapbox_maps_flutter_v3/example/lib/main.dart index e3dcd8777..4c95de5fd 100644 --- a/mapbox_maps_flutter_v3/example/lib/main.dart +++ b/mapbox_maps_flutter_v3/example/lib/main.dart @@ -20,12 +20,18 @@ class _MyAppState extends State { "MAPBOX_ACCESS_TOKEN", ); + late final MapboxMap _mapboxMap; + @override void initState() { super.initState(); MapboxOptions.setAccessToken(ACCESS_TOKEN); } + _onMapCreated(MapboxMap mapboxMap) { + _mapboxMap = mapboxMap; + } + @override Widget build(BuildContext context) { return MaterialApp( @@ -34,6 +40,7 @@ class _MyAppState extends State { body: Center( child: MapWidget( cameraOptions: CameraOptions(center: City.helsinki, zoom: 6), + onMapCreated: _onMapCreated, )), ), ); diff --git a/mapbox_maps_flutter_v3/lib/src/map_widget.dart b/mapbox_maps_flutter_v3/lib/src/map_widget.dart index 9c98961be..f34db46d2 100644 --- a/mapbox_maps_flutter_v3/lib/src/map_widget.dart +++ b/mapbox_maps_flutter_v3/lib/src/map_widget.dart @@ -1,19 +1,27 @@ import 'package:flutter/widgets.dart'; import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; +typedef MapboxMap = MapboxMapInterface; + class MapWidget extends StatelessWidget { final MapboxMapsFlutterPlatform _platform; /// The initial Camera options when creating a MapWidget. final CameraOptions? cameraOptions; + final OnMapCreated? onMapCreated; + MapWidget({ super.key, this.cameraOptions, + this.onMapCreated, }) : _platform = MapboxMapsFlutterPlatform.instance; @override Widget build(BuildContext context) { - return _platform.buildView(cameraOptions: cameraOptions); + return _platform.buildView( + cameraOptions: cameraOptions, + onMapCreated: onMapCreated, + ); } } diff --git a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart index 0b603b2a3..6c0d1d9bc 100644 --- a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart +++ b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart @@ -18,7 +18,10 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { late HTMLDivElement _mapElement; @override - Widget buildView({CameraOptions? cameraOptions}) { + Widget buildView({ + CameraOptions? cameraOptions, + OnMapCreated? onMapCreated, + }) { final viewType = 'mapbox-maps-flutter-web/$hashCode'; // Attach the mapDiv to the DOM From e4b1ae7bbb98b33156e8d06260f1a66cf002f364 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Thu, 15 May 2025 16:25:37 +0300 Subject: [PATCH 7/9] [web] implement camera get/set --- mapbox_maps_flutter_v3/example/lib/main.dart | 8 +++ mapbox_maps_flutter_v3/example/lib/utils.dart | 1 + .../lib/src/map_widget.dart | 29 ++++++++++ mapbox_maps_flutter_web/lib/src/bindings.dart | 55 ++++++++++++++++++- .../lib/src/conversion.dart | 36 ++++++++++++ .../lib/src/mapbox_map.dart | 45 +++++++++++++++ .../lib/src/mapbox_maps_flutter_web.dart | 31 ++++++++--- 7 files changed, 197 insertions(+), 8 deletions(-) create mode 100644 mapbox_maps_flutter_web/lib/src/conversion.dart create mode 100644 mapbox_maps_flutter_web/lib/src/mapbox_map.dart diff --git a/mapbox_maps_flutter_v3/example/lib/main.dart b/mapbox_maps_flutter_v3/example/lib/main.dart index 4c95de5fd..ba69b26da 100644 --- a/mapbox_maps_flutter_v3/example/lib/main.dart +++ b/mapbox_maps_flutter_v3/example/lib/main.dart @@ -30,6 +30,14 @@ class _MyAppState extends State { _onMapCreated(MapboxMap mapboxMap) { _mapboxMap = mapboxMap; + + Future.delayed(const Duration(seconds: 2), () { + _mapboxMap.setCamera( + CameraOptions( + center: City.saigon, + ), + ); + }); } @override diff --git a/mapbox_maps_flutter_v3/example/lib/utils.dart b/mapbox_maps_flutter_v3/example/lib/utils.dart index 85b109830..4aabe8e70 100644 --- a/mapbox_maps_flutter_v3/example/lib/utils.dart +++ b/mapbox_maps_flutter_v3/example/lib/utils.dart @@ -3,4 +3,5 @@ import 'package:mapbox_maps_flutter_v3/mapbox_maps_flutter_v3.dart'; extension City on Point { static Point get helsinki => Point(coordinates: Position.of([24.941, 60.173])); + static Point get saigon => Point(coordinates: Position.of([106.700, 10.776])); } diff --git a/mapbox_maps_flutter_v3/lib/src/map_widget.dart b/mapbox_maps_flutter_v3/lib/src/map_widget.dart index f34db46d2..ad727a5bf 100644 --- a/mapbox_maps_flutter_v3/lib/src/map_widget.dart +++ b/mapbox_maps_flutter_v3/lib/src/map_widget.dart @@ -3,12 +3,41 @@ import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart typedef MapboxMap = MapboxMapInterface; +/// A widget that displays a Mapbox map using the Mapbox Maps Flutter SDK. +/// +/// You use this class to display map information and to manipulate the map contents from your application. +/// You can center the map on a given coordinate, specify the size of the area you want to display, +/// and style the features of the map to fit your application's use case. +/// +/// Use of MapWidget requires a Mapbox API access token. +/// Obtain an access token on the [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). +/// +/// Warning: Please note that you are responsible for getting permission to use the map data, +/// and for ensuring your use adheres to the relevant terms of use. +/// +/// ### Example: +/// ```dart +/// MapWidget( +/// cameraOptions: CameraOptions( +/// center: LatLng(37.7749, -122.4194), +/// zoom: 12.0, +/// ), +/// onMapCreated: (controller) { +/// // Handle map creation logic here. +/// }, +/// ) +/// ``` class MapWidget extends StatelessWidget { final MapboxMapsFlutterPlatform _platform; /// The initial Camera options when creating a MapWidget. final CameraOptions? cameraOptions; + /// Callback that is triggered when the map has been successfully created. + /// + /// This provides an opportunity to perform additional setup or configuration + /// once the map is ready. The [OnMapCreated] callback can be used to access + /// the [MapboxMap] instance and interact with it. final OnMapCreated? onMapCreated; MapWidget({ diff --git a/mapbox_maps_flutter_web/lib/src/bindings.dart b/mapbox_maps_flutter_web/lib/src/bindings.dart index 44394d9a0..2370856ea 100644 --- a/mapbox_maps_flutter_web/lib/src/bindings.dart +++ b/mapbox_maps_flutter_web/lib/src/bindings.dart @@ -8,13 +8,66 @@ import 'package:web/web.dart'; @JS() external String accessToken; +@JS() +@anonymous +extension type LngLat._(JSObject _) implements JSObject { + external LngLat(num lng, num lat); + external num lat; + external num lng; +} + +@JS() +@anonymous +extension type CameraOptions._(JSObject _) implements JSObject { + external factory CameraOptions({ + LngLat? center, + PaddingOptions? padding, + double? zoom, + double? bearing, + double? pitch, + }); + external LngLat? center; + external PaddingOptions? padding; + external double? zoom; + external double? bearing; + external double? pitch; +} + +@JS() +@anonymous +extension type PaddingOptions._(JSObject _) implements JSObject { + external factory PaddingOptions({ + num top, + num left, + num bottom, + num right, + }); + external num top; + external num left; + external num bottom; + external num right; +} + @JS() @anonymous extension type MapOptions._(JSObject _) implements JSObject { - external factory MapOptions({required HTMLDivElement container}); + external factory MapOptions({ + required HTMLDivElement container, + LngLat? center, + PaddingOptions? padding, + double? zoom, + double? bearing, + double? pitch, + }); } extension type Map._(JSObject _) implements JSObject { external Map(MapOptions container); external void on(String event, JSFunction callback); + external void jumpTo(CameraOptions camera); + external LngLat getCenter(); + external PaddingOptions getPadding(); + external double getZoom(); + external double getBearing(); + external double getPitch(); } diff --git a/mapbox_maps_flutter_web/lib/src/conversion.dart b/mapbox_maps_flutter_web/lib/src/conversion.dart new file mode 100644 index 000000000..1846add2e --- /dev/null +++ b/mapbox_maps_flutter_web/lib/src/conversion.dart @@ -0,0 +1,36 @@ +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; +import 'package:mapbox_maps_flutter_web/src/bindings.dart'; + +extension PointToLngLat on Point { + LngLat toLngLat() { + return LngLat(coordinates.lng, coordinates.lat); + } +} + +extension LngLatToPoint on LngLat { + Point toPoint() { + return Point(coordinates: Position(lng, lat)); + } +} + +extension PaddingOptionsToMbxEdgeInsets on PaddingOptions { + MbxEdgeInsets toMbxEdgeInsets() { + return MbxEdgeInsets( + top: top.toDouble(), + left: left.toDouble(), + bottom: bottom.toDouble(), + right: right.toDouble(), + ); + } +} + +extension MbxEdgeInsetsToPaddingOptions on MbxEdgeInsets { + PaddingOptions toPaddingOptions() { + return PaddingOptions( + top: top, + left: left, + bottom: bottom, + right: right, + ); + } +} diff --git a/mapbox_maps_flutter_web/lib/src/mapbox_map.dart b/mapbox_maps_flutter_web/lib/src/mapbox_map.dart new file mode 100644 index 000000000..45cf2657e --- /dev/null +++ b/mapbox_maps_flutter_web/lib/src/mapbox_map.dart @@ -0,0 +1,45 @@ +import 'dart:js_interop'; + +import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; +import 'package:mapbox_maps_flutter_web/src/bindings.dart' as gl_js; +import 'package:mapbox_maps_flutter_web/src/conversion.dart'; + +final class MapboxMap extends MapboxMapInterface { + final gl_js.Map nativeMap; + + MapboxMap(this.nativeMap); + + @override + Future getCameraState() { + final camera = CameraState( + center: nativeMap.getCenter().toPoint(), + padding: nativeMap.getPadding().toMbxEdgeInsets(), + zoom: nativeMap.getZoom(), + bearing: nativeMap.getBearing(), + pitch: nativeMap.getPitch(), + ); + return Future.value(camera); + } + + @override + Future setCamera(CameraOptions cameraOptions) { + final options = gl_js.CameraOptions(); + if (cameraOptions.center != null) { + options.center = cameraOptions.center!.toLngLat(); + } + if (cameraOptions.padding != null) { + options.padding = cameraOptions.padding!.toPaddingOptions(); + } + if (cameraOptions.zoom != null) { + options.zoom = cameraOptions.zoom; + } + if (cameraOptions.bearing != null) { + options.bearing = cameraOptions.bearing; + } + if (cameraOptions.pitch != null) { + options.pitch = cameraOptions.pitch; + } + nativeMap.jumpTo(options); + return Future.value(); + } +} diff --git a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart index 6c0d1d9bc..12b05b150 100644 --- a/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart +++ b/mapbox_maps_flutter_web/lib/src/mapbox_maps_flutter_web.dart @@ -4,7 +4,9 @@ import 'dart:ui_web'; import 'package:flutter/widgets.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; -import 'package:mapbox_maps_flutter_web/src/bindings.dart'; +import 'package:mapbox_maps_flutter_web/src/bindings.dart' as gl_js; +import 'package:mapbox_maps_flutter_web/src/conversion.dart'; +import 'package:mapbox_maps_flutter_web/src/mapbox_map.dart'; import 'package:web/web.dart'; const mapboxGlCss = 'https://api.mapbox.com/mapbox-gl-js/v3.11.1/mapbox-gl.css'; @@ -33,13 +35,19 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { ..style.height = '100%' ..style.width = '100%'; - _initMap(); + _initMap( + cameraOptions: cameraOptions, + onMapCreated: onMapCreated, + ); return _mapElement; }); return HtmlElementView(viewType: viewType); } - _initMap() async { + _initMap({ + CameraOptions? cameraOptions, + OnMapCreated? onMapCreated, + }) async { final link = document.createElement('link') as HTMLLinkElement ..rel = 'stylesheet' ..href = mapboxGlCss @@ -48,19 +56,28 @@ base class MapboxMapsFlutterWeb extends MapboxMapsFlutterPlatform { await link.onLoad.first; - final options = MapOptions(container: _mapElement); - final nativeMap = Map(options); + final options = gl_js.MapOptions( + container: _mapElement, + center: cameraOptions?.center?.toLngLat(), + padding: cameraOptions?.padding?.toPaddingOptions(), + zoom: cameraOptions?.zoom, + bearing: cameraOptions?.bearing, + pitch: cameraOptions?.pitch, + ); + final nativeMap = gl_js.Map(options); + + onMapCreated?.call(MapboxMap(nativeMap)); nativeMap.on('load', (() {}).toJS); } @override Future getAccessToken() { - return Future.value(accessToken); + return Future.value(gl_js.accessToken); } @override void setAccessToken(String token) { - accessToken = token; + gl_js.accessToken = token; } } From d5ebd56f6ec9380cea8ddb9d4cde6988ffd16a89 Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Fri, 16 May 2025 12:10:35 +0300 Subject: [PATCH 8/9] Fix android and address reviews --- .../lib/mapbox_maps_flutter_interface.dart | 5 ++++- .../lib/src/turf_adapter.dart | 6 +----- .../pigeons/PlatformInterfaceDataTypes.kt | 12 ------------ .../example/integration_test/animation_test.dart | 2 -- .../example/integration_test/camera_test.dart | 2 -- .../example/integration_test/empty_map_widget.dart | 2 -- .../example/integration_test/gestures_test.dart | 2 -- .../integration_test/interactive_features_test.dart | 3 +-- .../example/integration_test/map_interface_test.dart | 2 -- .../example/integration_test/viewport_test.dart | 3 +-- .../example/lib/animated_route_example.dart | 2 -- .../example/lib/animation_example.dart | 3 +-- .../example/lib/camera_example.dart | 3 +-- .../example/lib/circle_annotations_example.dart | 3 +-- .../example/lib/cluster_example.dart | 3 +-- .../example/lib/edit_polygon_example.dart | 2 -- .../example/lib/full_map_example.dart | 3 +-- .../example/lib/geojson_line_example.dart | 3 +-- .../example/lib/image_source_example.dart | 2 -- .../example/lib/map_interface_example.dart | 2 -- .../example/lib/model_layer_example.dart | 2 -- .../lib/model_layer_interactions_example.dart | 2 -- .../example/lib/offline_map_example.dart | 2 -- .../example/lib/ornaments_example.dart | 2 -- .../example/lib/point_annotations_example.dart | 2 -- .../example/lib/polygon_annotations_example.dart | 2 -- .../example/lib/polyline_annotations_example.dart | 2 -- .../example/lib/standard_style_import_example.dart | 3 --- .../lib/standard_style_interactions_example.dart | 2 -- .../example/lib/tile_json_example.dart | 3 +-- .../example/lib/traffic_layer_example.dart | 2 -- .../example/lib/traffic_route_line_example.dart | 2 -- .../example/lib/vector_tile_source_example.dart | 2 -- .../lib/mapbox_maps_flutter.dart | 4 +--- mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart | 10 ++++------ .../lib/src/mapbox_maps_flutter_mobile.dart | 3 --- .../src/viewport/states/overview_viewport_state.dart | 2 +- mapbox_maps_flutter_v3/lib/src/map_widget.dart | 4 ++-- 38 files changed, 22 insertions(+), 94 deletions(-) rename mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart => mapbox_maps_flutter_interface/lib/src/turf_adapter.dart (95%) diff --git a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart index 2bfe0a952..00dda3617 100644 --- a/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart +++ b/mapbox_maps_flutter_interface/lib/mapbox_maps_flutter_interface.dart @@ -5,6 +5,9 @@ export 'src/map_interface.dart'; export 'src/callbacks.dart'; export 'package:turf/helpers.dart'; -import 'package:turf/turf.dart'; +import 'dart:convert'; + +import 'package:turf/turf.dart' as turf; part 'src/pigeons/platform_interface_data_types.dart'; +part 'src/turf_adapter.dart'; diff --git a/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart b/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart similarity index 95% rename from mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart rename to mapbox_maps_flutter_interface/lib/src/turf_adapter.dart index 70117c5b8..24e56f491 100644 --- a/mapbox_maps_flutter_mobile/lib/src/turf_adapters.dart +++ b/mapbox_maps_flutter_interface/lib/src/turf_adapter.dart @@ -1,4 +1,4 @@ -part of mapbox_maps_flutter; +part of 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; final class Point extends turf.Point { Point({super.bbox, required super.coordinates}); @@ -8,10 +8,6 @@ final class Point extends turf.Point { return Point(bbox: turfPoint.bbox, coordinates: turfPoint.coordinates); } - factory Point._from(turf.Point point) { - return Point(bbox: point.bbox, coordinates: point.coordinates); - } - static Point decode(Object result) { var map = (result is List) ? result.first : result; return Point.fromJson((map as Map).cast()); diff --git a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt index d400f0c91..0560ffa4d 100644 --- a/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt +++ b/mapbox_maps_flutter_mobile/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/pigeons/PlatformInterfaceDataTypes.kt @@ -7,18 +7,6 @@ package com.mapbox.maps.mapbox_maps.pigeons import com.mapbox.geojson.Point import com.mapbox.maps.mapbox_maps.mapping.turf.* -/** - * Error class for passing custom error details to Flutter via a thrown PlatformException. - * @property code The error code. - * @property message The error message. - * @property details The error details. Must be a datatype supported by the api codec. - */ -class FlutterError( - val code: String, - override val message: String? = null, - val details: Any? = null -) : Throwable() - /** * Describes the coordinate on the screen, measured from top to bottom and from left to right. * Note: the `map` uses screen coordinate units measured in `logical pixels`. diff --git a/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart index b1ba97c0a..260c54096 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/animation_test.dart @@ -3,8 +3,6 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show MbxEdgeInsets, CameraOptions, ScreenCoordinate; import 'empty_map_widget.dart' as app; diff --git a/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart index 01170fdf2..43611f2e2 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/camera_test.dart @@ -1,8 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show MbxEdgeInsets, CameraOptions, ScreenCoordinate; import 'empty_map_widget.dart' as app; diff --git a/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart b/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart index e4c79b55a..d3c10abf2 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/empty_map_widget.dart @@ -2,8 +2,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; class Events { var onMapIdle = Completer(); diff --git a/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart index a74926012..9ff632048 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/gestures_test.dart @@ -3,8 +3,6 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show ScreenCoordinate; import 'empty_map_widget.dart' as app; diff --git a/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart index 0f6f18e6f..54bc0f5e3 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/interactive_features_test.dart @@ -3,8 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions, ScreenCoordinate; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart index a6152108d..e9ef8d7c0 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/map_interface_test.dart @@ -5,8 +5,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions, ScreenCoordinate; import 'empty_map_widget.dart' as app; diff --git a/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart b/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart index 457b3e1b5..0153f1818 100644 --- a/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart +++ b/mapbox_maps_flutter_mobile/example/integration_test/viewport_test.dart @@ -3,8 +3,7 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; + import 'empty_map_widget.dart' as app; void main() { diff --git a/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart b/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart index bc8f256c5..41cc8f5e0 100644 --- a/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/animated_route_example.dart @@ -9,8 +9,6 @@ import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'package:mapbox_maps_example/main.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:geolocator/geolocator.dart' show Geolocator; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show MbxEdgeInsets, CameraOptions, Point; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/animation_example.dart b/mapbox_maps_flutter_mobile/example/lib/animation_example.dart index 89b498f04..c8199bfba 100644 --- a/mapbox_maps_flutter_mobile/example/lib/animation_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/animation_example.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions, ScreenCoordinate; + import 'example.dart'; class AnimationExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/camera_example.dart b/mapbox_maps_flutter_mobile/example/lib/camera_example.dart index 3362678ad..1a47c3b86 100644 --- a/mapbox_maps_flutter_mobile/example/lib/camera_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/camera_example.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show MbxEdgeInsets, CameraOptions, ScreenCoordinate; + import 'example.dart'; class CameraExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart index 24411b508..901ee3898 100644 --- a/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/circle_annotations_example.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart' hide Visibility; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; + import 'example.dart'; class CircleAnnotationExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart b/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart index c8b0cc054..e5118e947 100644 --- a/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/cluster_example.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions, ScreenCoordinate; + import 'example.dart'; class StyleClustersExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart b/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart index d901e1fcc..a2eb33cd6 100644 --- a/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/edit_polygon_example.dart @@ -4,8 +4,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_example/example.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; class EditPolygonExample extends StatefulWidget implements Example { @override diff --git a/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart b/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart index a5ff1c3e5..e4c0d4e26 100644 --- a/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/full_map_example.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions, CameraState; + import 'example.dart'; class FullMapExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart b/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart index 906881fe1..8155befca 100644 --- a/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/geojson_line_example.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; + import 'example.dart'; class DrawGeoJsonLineExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart b/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart index 5e08d78ab..345592f21 100644 --- a/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/image_source_example.dart @@ -3,8 +3,6 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart b/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart index a615482e9..824c3c939 100644 --- a/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/map_interface_example.dart @@ -3,8 +3,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show ScreenCoordinate; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart b/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart index 5172d7f7e..bd9781b4c 100644 --- a/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/model_layer_example.dart @@ -2,8 +2,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart b/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart index f4de9afb2..31f6eedbb 100644 --- a/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/model_layer_interactions_example.dart @@ -2,8 +2,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart b/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart index b9861abd9..7500752b0 100644 --- a/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/offline_map_example.dart @@ -2,8 +2,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; import 'utils.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart b/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart index a0f373628..9ae1be37f 100644 --- a/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/ornaments_example.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart index 90667bef8..a8afb29b0 100644 --- a/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/point_annotations_example.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'package:mapbox_maps_example/utils.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart index 6ec557ee3..c66efbcef 100644 --- a/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/polygon_annotations_example.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_example/utils.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart b/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart index 194114989..96d053c74 100644 --- a/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/polyline_annotations_example.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'utils.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart b/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart index 7131096a5..ae8ad4aa4 100644 --- a/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/standard_style_import_example.dart @@ -4,9 +4,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; import 'example.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; - class StandardStyleImportExample extends StatefulWidget implements Example { @override final Widget leading = const Icon(Icons.touch_app); diff --git a/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart b/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart index 1760ec1b1..28a1d9589 100644 --- a/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/standard_style_interactions_example.dart @@ -1,8 +1,6 @@ import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart b/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart index 32930de35..dfb0f4ccd 100644 --- a/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/tile_json_example.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; + import 'example.dart'; class TileJsonExample extends StatefulWidget implements Example { diff --git a/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart b/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart index ae4939bd5..28ae41bc8 100644 --- a/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/traffic_layer_example.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart' hide Visibility; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart b/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart index 32fc32c4b..276e18816 100644 --- a/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/traffic_route_line_example.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'example.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; class TrafficRouteLineExample extends StatefulWidget implements Example { @override diff --git a/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart b/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart index ccbe183f9..c0be7a3df 100644 --- a/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart +++ b/mapbox_maps_flutter_mobile/example/lib/vector_tile_source_example.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart'; -import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart' - show CameraOptions; import 'example.dart'; diff --git a/mapbox_maps_flutter_mobile/lib/mapbox_maps_flutter.dart b/mapbox_maps_flutter_mobile/lib/mapbox_maps_flutter.dart index a60585993..3aa21a463 100644 --- a/mapbox_maps_flutter_mobile/lib/mapbox_maps_flutter.dart +++ b/mapbox_maps_flutter_mobile/lib/mapbox_maps_flutter.dart @@ -11,9 +11,8 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; import 'package:meta/meta.dart'; -import 'package:turf/turf.dart' as turf; -export 'package:turf/helpers.dart'; +export 'package:mapbox_maps_flutter_interface/mapbox_maps_flutter_interface.dart'; part 'src/annotation/circle_annotation_manager.dart'; part 'src/annotation/point_annotation_manager.dart'; @@ -66,7 +65,6 @@ part 'src/style/interactive_features/standard_poi.dart'; part 'src/location_settings.dart'; part 'src/snapshotter/snapshotter.dart'; part 'src/log_configuration.dart'; -part 'src/turf_adapters.dart'; part 'src/extensions.dart'; part 'src/map_events.dart'; part 'src/offline/offline_messenger.dart'; diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart index 15b1aa805..531347ae2 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart @@ -345,12 +345,10 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// It is not guaranteed that the provided `camera options` will be set, the map may apply constraints resulting in a /// different `camera state`. @override - Future setCamera(CameraOptions cameraOptions) { - if (cameraOptions.center != null) { - cameraOptions.center = Point._from(cameraOptions.center!); - } - return _cameraManager.setCamera(cameraOptions); - } + Future setCamera(CameraOptions cameraOptions) => + _cameraManager.setCamera( + cameraOptions, + ); /// Returns the current `camera state`. @override diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart index 6b42c0fc7..59ef402a7 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_maps_flutter_mobile.dart @@ -6,9 +6,6 @@ base class MapboxMapsFlutterMobile extends MapboxMapsFlutterPlatform { CameraOptions? cameraOptions, OnMapCreated? onMapCreated, }) { - if (cameraOptions?.center != null) { - cameraOptions?.center = Point._from(cameraOptions.center!); - } return MapWidget( cameraOptions: cameraOptions, onMapCreated: (MapboxMap mapboxMap) { diff --git a/mapbox_maps_flutter_mobile/lib/src/viewport/states/overview_viewport_state.dart b/mapbox_maps_flutter_mobile/lib/src/viewport/states/overview_viewport_state.dart index a1cdc37ca..0c7789583 100644 --- a/mapbox_maps_flutter_mobile/lib/src/viewport/states/overview_viewport_state.dart +++ b/mapbox_maps_flutter_mobile/lib/src/viewport/states/overview_viewport_state.dart @@ -21,7 +21,7 @@ part of mapbox_maps_flutter; /// ``` final class OverviewViewportState extends ViewportState { /// The geometry to display in the overview. - final turf.GeometryObject geometry; + final GeometryObject geometry; /// Extra padding to add around the [geometry]. /// diff --git a/mapbox_maps_flutter_v3/lib/src/map_widget.dart b/mapbox_maps_flutter_v3/lib/src/map_widget.dart index ad727a5bf..5cc7f2e2a 100644 --- a/mapbox_maps_flutter_v3/lib/src/map_widget.dart +++ b/mapbox_maps_flutter_v3/lib/src/map_widget.dart @@ -19,10 +19,10 @@ typedef MapboxMap = MapboxMapInterface; /// ```dart /// MapWidget( /// cameraOptions: CameraOptions( -/// center: LatLng(37.7749, -122.4194), +/// center: Point(37.7749, -122.4194), /// zoom: 12.0, /// ), -/// onMapCreated: (controller) { +/// onMapCreated: (mapboxMap) { /// // Handle map creation logic here. /// }, /// ) From 1eadb636bb1a6a2bb06b2a4c9e96de477f7395af Mon Sep 17 00:00:00 2001 From: Mai Mai Date: Fri, 16 May 2025 12:34:40 +0300 Subject: [PATCH 9/9] remove accidental experimental tag --- mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart index 531347ae2..cb6f2993d 100644 --- a/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart +++ b/mapbox_maps_flutter_mobile/lib/src/mapbox_map.dart @@ -462,7 +462,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { options); /// Queries the map for rendered features with one typed featureset. - @experimental Future> queryRenderedFeaturesForFeatureset( {required FeaturesetDescriptor featureset, RenderedQueryGeometry? geometry, @@ -520,7 +519,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// Update the state map of a feature within a featureset. /// Update entries in the state map of a given feature within a style source. Only entries listed in the state map /// will be updated. An entry in the feature state map that is not listed in `state` will retain its previous value. - @experimental Future setFeatureStateForFeaturesetDescriptor( FeaturesetDescriptor featureset, FeaturesetFeatureId featureId, @@ -532,7 +530,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// /// The feature should have a non-nil ``FeaturesetFeatureType/id``. Otherwise, /// the operation will be no-op and callback will receive an error. - @experimental Future setFeatureStateForFeaturesetFeature( FeaturesetFeature feature, FeatureState state) => _mapInterface.setFeatureStateForFeaturesetFeature(feature, state.map); @@ -546,14 +543,12 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { _mapInterface.getFeatureState(sourceId, sourceLayerId, featureId); /// Get the state map of a feature within a style source. - @experimental Future> getFeatureStateForFeaturesetDescriptor( FeaturesetDescriptor featureset, FeaturesetFeatureId featureId) => _mapInterface.getFeatureStateForFeaturesetDescriptor( featureset, featureId); /// Get the state map of a feature within a style source. - @experimental Future> getFeatureStateForFeaturesetFeature( FeaturesetFeature feature) => _mapInterface.getFeatureStateForFeaturesetFeature(feature); @@ -572,7 +567,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// Removes entries from a feature state object of a feature in the specified featureset. /// Remove a specified property or all property from a feature's state object, depending on the value of `stateKey`. - @experimental Future removeFeatureStateForFeaturesetDescriptor( {required FeaturesetDescriptor featureset, required FeaturesetFeatureId featureId, @@ -582,7 +576,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// Removes entries from a specified Feature. /// Remove a specified property or all property from a feature's state object, depending on the value of `stateKey`. - @experimental Future removeFeatureStateForFeaturesetFeature( {required FeaturesetFeature feature, String? stateKey}) => _mapInterface.removeFeatureStateForFeaturesetFeature(feature, stateKey); @@ -591,19 +584,16 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// /// Note that updates to feature state are asynchronous, so changes made by this method might not be /// immediately visible using ``MapboxMap/getFeatureState(_:callback:)``. - @experimental Future resetFeatureStatesForFeatureset( FeaturesetDescriptor featureset) => _mapInterface.resetFeatureStatesForFeatureset(featureset); /// References for all interactions added to the map. - @experimental final _InteractionsMap _interactionsMap = _InteractionsMap(interactions: {}); /// Add an interaction to the map /// An identifier can be provided, which you can use to remove /// the interaction with `.removeInteraction(interactionID)` - @experimental void addInteraction>( TypedInteraction interaction, {String? interactionID}) { @@ -620,7 +610,6 @@ final class MapboxMap extends MapboxMapInterface with ChangeNotifier { /// Remove an interaction from the map with the given interactionID /// that was passed with `.addInteraction(interaction, interactionID)` - @experimental void removeInteraction(String interactionID) { _interactionsMap.interactions.remove(interactionID); _mapboxMapsPlatform.removeInteractionsListeners(interactionID);