diff --git a/.github/workflows/flutter_ci.yml b/.github/workflows/flutter_ci.yml index 24f40a2e..d1462d85 100644 --- a/.github/workflows/flutter_ci.yml +++ b/.github/workflows/flutter_ci.yml @@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch] env: FLUTTER_CHANNEL: 'stable' - FLUTTER_VERSION: '2.5.3' + FLUTTER_VERSION: '2.10.5' jobs: format: diff --git a/android/build.gradle b/android/build.gradle index 2584c716..eb98adf9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ version '1.0-SNAPSHOT' buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { @@ -15,7 +15,6 @@ buildscript { rootProject.allprojects { repositories { google() - jcenter() mavenCentral() } } @@ -23,7 +22,9 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 29 + + compileSdkVersion 31 + ndkVersion "20.1.5948944" defaultConfig { minSdkVersion 20 diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6d6819d3..2c6f16a9 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -25,7 +25,8 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 + ndkVersion "20.1.5948944" lintOptions { disable 'InvalidPackage' @@ -35,7 +36,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.mapbox.mapboxglexample" minSdkVersion 20 - targetSdkVersion 28 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 32dd1347..a8a23b43 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -5,12 +5,13 @@ initPlatform(int id) async { - await MapLibreGlPlatform.getInstance(id).initPlatform(id); - } - final OnStyleLoadedCallback? onStyleLoadedCallback; final OnMapClickCallback? onMapClick; @@ -241,14 +207,14 @@ class MaplibreMapController extends ChangeNotifier { CameraPosition? get cameraPosition => _cameraPosition; CameraPosition? _cameraPosition; - final int _id; //ignore: unused_field + final MapLibreGlPlatform _mapboxGlPlatform; //ignore: unused_field Widget buildView( Map creationParams, OnPlatformViewCreatedCallback onPlatformViewCreated, Set> gestureRecognizers) { - return MapLibreGlPlatform.getInstance(_id) - .buildView(creationParams, onPlatformViewCreated, gestureRecognizers); + return _mapboxGlPlatform.buildView( + creationParams, onPlatformViewCreated, gestureRecognizers); } /// Updates configuration options of the map user interface. @@ -258,8 +224,7 @@ class MaplibreMapController extends ChangeNotifier { /// /// The returned [Future] completes after listeners have been notified. Future _updateMapOptions(Map optionsUpdate) async { - _cameraPosition = await MapLibreGlPlatform.getInstance(_id) - .updateMapOptions(optionsUpdate); + _cameraPosition = await _mapboxGlPlatform.updateMapOptions(optionsUpdate); notifyListeners(); } @@ -270,7 +235,7 @@ class MaplibreMapController extends ChangeNotifier { /// It returns true if the camera was successfully moved and false if the movement was canceled. /// Note: this currently always returns immediately with a value of null on iOS Future animateCamera(CameraUpdate cameraUpdate) async { - return MapLibreGlPlatform.getInstance(_id).animateCamera(cameraUpdate); + return _mapboxGlPlatform.animateCamera(cameraUpdate); } /// Instantaneously re-position the camera. @@ -281,7 +246,7 @@ class MaplibreMapController extends ChangeNotifier { /// It returns true if the camera was successfully moved and false if the movement was canceled. /// Note: this currently always returns immediately with a value of null on iOS Future moveCamera(CameraUpdate cameraUpdate) async { - return MapLibreGlPlatform.getInstance(_id).moveCamera(cameraUpdate); + return _mapboxGlPlatform.moveCamera(cameraUpdate); } /// Updates user location tracking mode. @@ -290,7 +255,7 @@ class MaplibreMapController extends ChangeNotifier { /// platform side. Future updateMyLocationTrackingMode( MyLocationTrackingMode myLocationTrackingMode) async { - return MapLibreGlPlatform.getInstance(_id) + return _mapboxGlPlatform .updateMyLocationTrackingMode(myLocationTrackingMode); } @@ -299,8 +264,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future matchMapLanguageWithDeviceDefault() async { - return MapLibreGlPlatform.getInstance(_id) - .matchMapLanguageWithDeviceDefault(); + return _mapboxGlPlatform.matchMapLanguageWithDeviceDefault(); } /// Updates the distance from the edges of the map view’s frame to the edges @@ -316,8 +280,7 @@ class MaplibreMapController extends ChangeNotifier { /// platform side. Future updateContentInsets(EdgeInsets insets, [bool animated = false]) async { - return MapLibreGlPlatform.getInstance(_id) - .updateContentInsets(insets, animated); + return _mapboxGlPlatform.updateContentInsets(insets, animated); } /// Updates the language of the map labels to match the specified language. @@ -327,7 +290,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future setMapLanguage(String language) async { - return MapLibreGlPlatform.getInstance(_id).setMapLanguage(language); + return _mapboxGlPlatform.setMapLanguage(language); } /// Enables or disables the collection of anonymized telemetry data. @@ -335,7 +298,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future setTelemetryEnabled(bool enabled) async { - return MapLibreGlPlatform.getInstance(_id).setTelemetryEnabled(enabled); + return _mapboxGlPlatform.setTelemetryEnabled(enabled); } /// Retrieves whether collection of anonymized telemetry data is enabled. @@ -343,7 +306,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes after the query has been made on the /// platform side. Future getTelemetryEnabled() async { - return MapLibreGlPlatform.getInstance(_id).getTelemetryEnabled(); + return _mapboxGlPlatform.getTelemetryEnabled(); } /// Adds a symbol to the map, configured using the specified custom [options]. @@ -373,8 +336,7 @@ class MaplibreMapController extends ChangeNotifier { final List effectiveOptions = options.map((o) => SymbolOptions.defaultOptions.copyWith(o)).toList(); - final symbols = await MapLibreGlPlatform.getInstance(_id) - .addSymbols(effectiveOptions, data); + final symbols = await _mapboxGlPlatform.addSymbols(effectiveOptions, data); symbols.forEach((s) => _symbols[s.id] = s); notifyListeners(); return symbols; @@ -389,7 +351,8 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future updateSymbol(Symbol symbol, SymbolOptions changes) async { assert(_symbols[symbol.id] == symbol); - await MapLibreGlPlatform.getInstance(_id).updateSymbol(symbol, changes); + + await _mapboxGlPlatform.updateSymbol(symbol, changes); symbol.options = symbol.options.copyWith(changes); notifyListeners(); } @@ -399,8 +362,7 @@ class MaplibreMapController extends ChangeNotifier { /// In that case this method provides the symbol's actual position, and `symbol.options.geometry` the last programmatically set position. Future getSymbolLatLng(Symbol symbol) async { assert(_symbols[symbol.id] == symbol); - final symbolLatLng = - await MapLibreGlPlatform.getInstance(_id).getSymbolLatLng(symbol); + final symbolLatLng = await _mapboxGlPlatform.getSymbolLatLng(symbol); notifyListeners(); return symbolLatLng; } @@ -440,7 +402,7 @@ class MaplibreMapController extends ChangeNotifier { /// /// The returned [Future] completes once listeners have been notified. Future clearSymbols() async { - await MapLibreGlPlatform.getInstance(_id).removeSymbols(_symbols.keys); + await _mapboxGlPlatform.removeSymbols(_symbols.keys); _symbols.clear(); notifyListeners(); } @@ -451,7 +413,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once the symbol has been removed from /// [_symbols]. Future _removeSymbols(Iterable ids) async { - await MapLibreGlPlatform.getInstance(_id).removeSymbols(ids); + await _mapboxGlPlatform.removeSymbols(ids); _symbols.removeWhere((k, s) => ids.contains(k)); } @@ -465,8 +427,7 @@ class MaplibreMapController extends ChangeNotifier { Future addLine(LineOptions options, [Map? data]) async { final LineOptions effectiveOptions = LineOptions.defaultOptions.copyWith(options); - final line = await MapLibreGlPlatform.getInstance(_id) - .addLine(effectiveOptions, data); + final line = await _mapboxGlPlatform.addLine(effectiveOptions, data); _lines[line.id] = line; notifyListeners(); return line; @@ -481,8 +442,7 @@ class MaplibreMapController extends ChangeNotifier { /// been notified. Future> addLines(List options, [List? data]) async { - final lines = - await MapLibreGlPlatform.getInstance(_id).addLines(options, data); + final lines = await _mapboxGlPlatform.addLines(options, data); lines.forEach((l) => _lines[l.id] = l); notifyListeners(); return lines; @@ -497,7 +457,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future updateLine(Line line, LineOptions changes) async { assert(_lines[line.id] == line); - await MapLibreGlPlatform.getInstance(_id).updateLine(line, changes); + await _mapboxGlPlatform.updateLine(line, changes); line.options = line.options.copyWith(changes); notifyListeners(); } @@ -507,8 +467,7 @@ class MaplibreMapController extends ChangeNotifier { /// In that case this method provides the line's actual position, and `line.options.geometry` the last programmatically set position. Future> getLineLatLngs(Line line) async { assert(_lines[line.id] == line); - final lineLatLngs = - await MapLibreGlPlatform.getInstance(_id).getLineLatLngs(line); + final lineLatLngs = await _mapboxGlPlatform.getLineLatLngs(line); notifyListeners(); return lineLatLngs; } @@ -523,7 +482,7 @@ class MaplibreMapController extends ChangeNotifier { Future removeLine(Line line) async { assert(_lines[line.id] == line); - await MapLibreGlPlatform.getInstance(_id).removeLine(line.id); + await _mapboxGlPlatform.removeLine(line.id); _lines.remove(line.id); notifyListeners(); } @@ -539,7 +498,7 @@ class MaplibreMapController extends ChangeNotifier { final ids = lines.where((l) => _lines[l.id] == l).map((l) => l.id); assert(lines.length == ids.length); - await MapLibreGlPlatform.getInstance(_id).removeLines(ids); + await _mapboxGlPlatform.removeLines(ids); ids.forEach((id) => _lines.remove(id)); notifyListeners(); } @@ -552,7 +511,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future clearLines() async { final List lineIds = List.from(_lines.keys); - await MapLibreGlPlatform.getInstance(_id).removeLines(lineIds); + await _mapboxGlPlatform.removeLines(lineIds); _lines.clear(); notifyListeners(); } @@ -567,8 +526,7 @@ class MaplibreMapController extends ChangeNotifier { Future addCircle(CircleOptions options, [Map? data]) async { final CircleOptions effectiveOptions = CircleOptions.defaultOptions.copyWith(options); - final circle = await MapLibreGlPlatform.getInstance(_id) - .addCircle(effectiveOptions, data); + final circle = await _mapboxGlPlatform.addCircle(effectiveOptions, data); _circles[circle.id] = circle; notifyListeners(); return circle; @@ -584,8 +542,7 @@ class MaplibreMapController extends ChangeNotifier { /// been notified. Future> addCircles(List options, [List? data]) async { - final circles = - await MapLibreGlPlatform.getInstance(_id).addCircles(options, data); + final circles = await _mapboxGlPlatform.addCircles(options, data); circles.forEach((c) => _circles[c.id] = c); notifyListeners(); return circles; @@ -600,7 +557,8 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future updateCircle(Circle circle, CircleOptions changes) async { assert(_circles[circle.id] == circle); - await MapLibreGlPlatform.getInstance(_id).updateCircle(circle, changes); + await _mapboxGlPlatform.updateCircle(circle, changes); + circle.options = circle.options.copyWith(changes); notifyListeners(); } @@ -609,8 +567,7 @@ class MaplibreMapController extends ChangeNotifier { /// In that case this method provides the circle's actual position, and `circle.options.geometry` the last programmatically set position. Future getCircleLatLng(Circle circle) async { assert(_circles[circle.id] == circle); - final circleLatLng = - await MapLibreGlPlatform.getInstance(_id).getCircleLatLng(circle); + final circleLatLng = await _mapboxGlPlatform.getCircleLatLng(circle); notifyListeners(); return circleLatLng; } @@ -625,7 +582,7 @@ class MaplibreMapController extends ChangeNotifier { Future removeCircle(Circle circle) async { assert(_circles[circle.id] == circle); - await MapLibreGlPlatform.getInstance(_id).removeCircle(circle.id); + await _mapboxGlPlatform.removeCircle(circle.id); _circles.remove(circle.id); notifyListeners(); @@ -642,7 +599,7 @@ class MaplibreMapController extends ChangeNotifier { final ids = circles.where((c) => _circles[c.id] == c).map((c) => c.id); assert(circles.length == ids.length); - await MapLibreGlPlatform.getInstance(_id).removeCircles(ids); + await _mapboxGlPlatform.removeCircles(ids); ids.forEach((id) => _circles.remove(id)); notifyListeners(); } @@ -654,7 +611,7 @@ class MaplibreMapController extends ChangeNotifier { /// /// The returned [Future] completes once listeners have been notified. Future clearCircles() async { - await MapLibreGlPlatform.getInstance(_id).removeCircles(_circles.keys); + await _mapboxGlPlatform.removeCircles(_circles.keys); _circles.clear(); notifyListeners(); @@ -670,8 +627,7 @@ class MaplibreMapController extends ChangeNotifier { Future addFill(FillOptions options, [Map? data]) async { final FillOptions effectiveOptions = FillOptions.defaultOptions.copyWith(options); - final fill = await MapLibreGlPlatform.getInstance(_id) - .addFill(effectiveOptions, data); + final fill = await _mapboxGlPlatform.addFill(effectiveOptions, data); _fills[fill.id] = fill; notifyListeners(); return fill; @@ -687,8 +643,7 @@ class MaplibreMapController extends ChangeNotifier { /// been notified. Future> addFills(List options, [List? data]) async { - final circles = - await MapLibreGlPlatform.getInstance(_id).addFills(options, data); + final circles = await _mapboxGlPlatform.addFills(options, data); circles.forEach((f) => _fills[f.id] = f); notifyListeners(); return circles; @@ -703,7 +658,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future updateFill(Fill fill, FillOptions changes) async { assert(_fills[fill.id] == fill); - await MapLibreGlPlatform.getInstance(_id).updateFill(fill, changes); + await _mapboxGlPlatform.updateFill(fill, changes); fill.options = fill.options.copyWith(changes); notifyListeners(); } @@ -715,7 +670,8 @@ class MaplibreMapController extends ChangeNotifier { /// /// The returned [Future] completes once listeners have been notified. Future clearFills() async { - await MapLibreGlPlatform.getInstance(_id).removeFills(_fills.keys); + await _mapboxGlPlatform.removeFills(_fills.keys); + _fills.clear(); notifyListeners(); } @@ -729,7 +685,7 @@ class MaplibreMapController extends ChangeNotifier { /// The returned [Future] completes once listeners have been notified. Future removeFill(Fill fill) async { assert(_fills[fill.id] == fill); - await MapLibreGlPlatform.getInstance(_id).removeFill(fill.id); + await _mapboxGlPlatform.removeFill(fill.id); _fills.remove(fill.id); notifyListeners(); @@ -746,37 +702,36 @@ class MaplibreMapController extends ChangeNotifier { final ids = fills.where((f) => _fills[f.id] == f).map((f) => f.id); assert(fills.length == ids.length); - await MapLibreGlPlatform.getInstance(_id).removeFills(ids); + await _mapboxGlPlatform.removeFills(ids); ids.forEach((id) => _fills.remove(id)); notifyListeners(); } Future queryRenderedFeatures( Point point, List layerIds, List? filter) async { - return MapLibreGlPlatform.getInstance(_id) - .queryRenderedFeatures(point, layerIds, filter); + return _mapboxGlPlatform.queryRenderedFeatures(point, layerIds, filter); } Future queryRenderedFeaturesInRect( Rect rect, List layerIds, String? filter) async { - return MapLibreGlPlatform.getInstance(_id) - .queryRenderedFeaturesInRect(rect, layerIds, filter); + return _mapboxGlPlatform.queryRenderedFeaturesInRect( + rect, layerIds, filter); } Future invalidateAmbientCache() async { - return MapLibreGlPlatform.getInstance(_id).invalidateAmbientCache(); + return _mapboxGlPlatform.invalidateAmbientCache(); } /// Get last my location /// /// Return last latlng, nullable Future requestMyLocationLatLng() async { - return MapLibreGlPlatform.getInstance(_id).requestMyLocationLatLng(); + return _mapboxGlPlatform.requestMyLocationLatLng(); } /// This method returns the boundaries of the region currently displayed in the map. Future getVisibleRegion() async { - return MapLibreGlPlatform.getInstance(_id).getVisibleRegion(); + return _mapboxGlPlatform.getVisibleRegion(); } /// Adds an image to the style currently displayed in the map, so that it can later be referred to by the provided name. @@ -815,59 +770,55 @@ class MaplibreMapController extends ChangeNotifier { /// } /// ``` Future addImage(String name, Uint8List bytes, [bool sdf = false]) { - return MapLibreGlPlatform.getInstance(_id).addImage(name, bytes, sdf); + return _mapboxGlPlatform.addImage(name, bytes, sdf); } /// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision Future setSymbolIconAllowOverlap(bool enable) async { - await MapLibreGlPlatform.getInstance(_id).setSymbolIconAllowOverlap(enable); + await _mapboxGlPlatform.setSymbolIconAllowOverlap(enable); } /// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision Future setSymbolIconIgnorePlacement(bool enable) async { - await MapLibreGlPlatform.getInstance(_id) - .setSymbolIconIgnorePlacement(enable); + await _mapboxGlPlatform.setSymbolIconIgnorePlacement(enable); } /// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision Future setSymbolTextAllowOverlap(bool enable) async { - await MapLibreGlPlatform.getInstance(_id).setSymbolTextAllowOverlap(enable); + await _mapboxGlPlatform.setSymbolTextAllowOverlap(enable); } /// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision Future setSymbolTextIgnorePlacement(bool enable) async { - await MapLibreGlPlatform.getInstance(_id) - .setSymbolTextIgnorePlacement(enable); + await _mapboxGlPlatform.setSymbolTextIgnorePlacement(enable); } /// Adds an image source to the style currently displayed in the map, so that it can later be referred to by the provided id. Future addImageSource( String imageSourceId, Uint8List bytes, LatLngQuad coordinates) { - return MapLibreGlPlatform.getInstance(_id) - .addImageSource(imageSourceId, bytes, coordinates); + return _mapboxGlPlatform.addImageSource(imageSourceId, bytes, coordinates); } /// Removes previously added image source by id Future removeImageSource(String imageSourceId) { - return MapLibreGlPlatform.getInstance(_id).removeImageSource(imageSourceId); + return _mapboxGlPlatform.removeImageSource(imageSourceId); } /// Adds a Mapbox style layer to the map's style at render time. Future addLayer(String imageLayerId, String imageSourceId) { - return MapLibreGlPlatform.getInstance(_id) - .addLayer(imageLayerId, imageSourceId); + return _mapboxGlPlatform.addLayer(imageLayerId, imageSourceId); } /// Adds a Mapbox style layer below the layer provided with belowLayerId to the map's style at render time, Future addLayerBelow( String imageLayerId, String imageSourceId, String belowLayerId) { - return MapLibreGlPlatform.getInstance(_id) - .addLayerBelow(imageLayerId, imageSourceId, belowLayerId); + return _mapboxGlPlatform.addLayerBelow( + imageLayerId, imageSourceId, belowLayerId); } /// Removes a Mapbox style layer Future removeLayer(String imageLayerId) { - return MapLibreGlPlatform.getInstance(_id).removeLayer(imageLayerId); + return _mapboxGlPlatform.removeLayer(imageLayerId); } /// Returns the point on the screen that corresponds to a geographical coordinate ([latLng]). The screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen) @@ -877,22 +828,21 @@ class MaplibreMapController extends ChangeNotifier { /// /// Returns null if [latLng] is not currently visible on the map. Future toScreenLocation(LatLng latLng) async { - return MapLibreGlPlatform.getInstance(_id).toScreenLocation(latLng); + return _mapboxGlPlatform.toScreenLocation(latLng); } Future> toScreenLocationBatch(Iterable latLngs) async { - return MapLibreGlPlatform.getInstance(_id).toScreenLocationBatch(latLngs); + return _mapboxGlPlatform.toScreenLocationBatch(latLngs); } /// Returns the geographic location (as [LatLng]) that corresponds to a point on the screen. The screen location is specified in screen pixels (not display pixels) relative to the top left of the map (not the top left of the whole screen). Future toLatLng(Point screenLocation) async { - return MapLibreGlPlatform.getInstance(_id).toLatLng(screenLocation); + return _mapboxGlPlatform.toLatLng(screenLocation); } /// Returns the distance spanned by one pixel at the specified [latitude] and current zoom level. /// The distance between pixels decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes. Future getMetersPerPixelAtLatitude(double latitude) async { - return MapLibreGlPlatform.getInstance(_id) - .getMetersPerPixelAtLatitude(latitude); + return _mapboxGlPlatform.getMetersPerPixelAtLatitude(latitude); } } diff --git a/lib/src/mapbox_map.dart b/lib/src/mapbox_map.dart index 3ef3bee3..0968077f 100644 --- a/lib/src/mapbox_map.dart +++ b/lib/src/mapbox_map.dart @@ -246,15 +246,16 @@ class _MaplibreMapState extends State { } Future onPlatformViewCreated(int id) async { - MapLibreGlPlatform.addInstance(id, _mapboxGlPlatform); - final MaplibreMapController controller = MaplibreMapController.init( - id, widget.initialCameraPosition, onStyleLoadedCallback: () { - if (_controller.isCompleted) { - widget.onStyleLoadedCallback!(); - } else { - _controller.future.then((_) => widget.onStyleLoadedCallback!()); - } - }, + final MaplibreMapController controller = MaplibreMapController( + mapboxGlPlatform: _mapboxGlPlatform, + initialCameraPosition: widget.initialCameraPosition, + onStyleLoadedCallback: () { + if (_controller.isCompleted) { + widget.onStyleLoadedCallback!(); + } else { + _controller.future.then((_) => widget.onStyleLoadedCallback!()); + } + }, onMapClick: widget.onMapClick, onUserLocationUpdated: widget.onUserLocationUpdated, onMapLongClick: widget.onMapLongClick, @@ -262,7 +263,7 @@ class _MaplibreMapState extends State { onCameraTrackingChanged: widget.onCameraTrackingChanged, onCameraIdle: widget.onCameraIdle, onMapIdle: widget.onMapIdle); - await MaplibreMapController.initPlatform(id); + await _mapboxGlPlatform.initPlatform(id); _controller.complete(controller); if (widget.onMapCreated != null) { widget.onMapCreated!(controller); diff --git a/maplibre_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/maplibre_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index d655b33e..63651caf 100644 --- a/maplibre_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/maplibre_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -15,16 +15,6 @@ abstract class MapLibreGlPlatform { static MapLibreGlPlatform Function() createInstance = () => MethodChannelMaplibreGl(); - static Map _instances = {}; - - static void addInstance(int id, MapLibreGlPlatform platform) { - _instances[id] = platform; - } - - static MapLibreGlPlatform getInstance(int id) { - return _instances[id]!; - } - final onInfoWindowTappedPlatform = ArgumentCallbacks(); final onSymbolTappedPlatform = ArgumentCallbacks(); diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index e4934cab..1955077c 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -114,8 +114,8 @@ class MethodChannelMaplibreGl extends MapLibreGlPlatform { @override Future initPlatform(int id) async { _channel = MethodChannel('plugins.flutter.io/mapbox_maps_$id'); - await _channel.invokeMethod('map#waitForMap'); _channel.setMethodCallHandler(_handleMethodCall); + await _channel.invokeMethod('map#waitForMap'); } @override diff --git a/pubspec.lock b/pubspec.lock index 0696a6bd..774fc336 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -66,14 +66,21 @@ packages: path: maplibre_gl_platform_interface relative: true source: path - version: "0.14.0" + version: "0.15.0" maplibre_gl_web: dependency: "direct main" description: path: maplibre_gl_web relative: true source: path - version: "0.14.0" + version: "0.15.0" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -95,6 +102,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.0" + platform: + dependency: "direct main" + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" sky_engine: dependency: transitive description: flutter