From a2afbbb6316dabae151e3c6915e9d72a751931cb Mon Sep 17 00:00:00 2001 From: Anton Averin Date: Fri, 23 Jul 2021 09:53:55 +0200 Subject: [PATCH 1/5] Fix optionals in location requests --- .../lib/src/method_channel_mapbox_gl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index e471f7d40..55b8ba77c 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -501,7 +501,7 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future requestMyLocationLatLng() async { try { - final Map reply = await _channel.invokeMethod( + final Map reply = await _channel.invokeMethod( 'locationComponent#getLastLocation', null); double latitude = 0.0, longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { From 904cb88e9e99239229b0a074dce3b271b4a6be0f Mon Sep 17 00:00:00 2001 From: Anton Averin Date: Sat, 11 Sep 2021 10:39:01 +0200 Subject: [PATCH 2/5] Make sure onStyleLoaded callback is invoked when map is loaded and ready --- ios/Classes/MapboxMapController.swift | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index 73482bbb7..0ff4c8f10 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -10,6 +10,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma private var mapView: MGLMapView private var isMapReady = false + private var isStyleReady = false private var mapReadyResult: FlutterResult? private var initialTilt: CGFloat? @@ -91,6 +92,13 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma case "map#waitForMap": if isMapReady { result(nil) + //Style could happen to been ready before the map was ready due to the order of methods invoked + //We should invoke onStyleLoaded + if isStyleReady { + if let channel = channel { + channel.invokeMethod("map#onStyleLoaded", arguments: nil) + } + } } else { mapReadyResult = result } @@ -873,10 +881,16 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } - mapReadyResult?(nil) - if let channel = channel { - channel.invokeMethod("map#onStyleLoaded", arguments: nil) + //If map is ready and map#waitForMap was called, we invoke onStyleLoaded callback directly + //If not, we will have to call it when map#waitForMap is done + if let mapReadyResult = mapReadyResult { + mapReadyResult(nil) + if let channel = channel { + channel.invokeMethod("map#onStyleLoaded", arguments: nil) + } } + + isStyleReady = true } func mapView(_ mapView: MGLMapView, shouldChangeFrom oldCamera: MGLMapCamera, to newCamera: MGLMapCamera) -> Bool { From 7fd342b80dfd295bacd70fda53cce357e8e077a2 Mon Sep 17 00:00:00 2001 From: Anton Averin Date: Mon, 4 Oct 2021 09:55:52 +0200 Subject: [PATCH 3/5] Update iOS SDK --- ios/mapbox_gl.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox_gl.podspec b/ios/mapbox_gl.podspec index c4f46d333..a43a7f041 100644 --- a/ios/mapbox_gl.podspec +++ b/ios/mapbox_gl.podspec @@ -16,7 +16,7 @@ A new Flutter plugin. s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.dependency 'MapboxAnnotationExtension', '~> 0.0.1-beta.1' - s.dependency 'Mapbox-iOS-SDK', '~> 6.3.0' + s.dependency 'Mapbox-iOS-SDK', '~> 6.4.0' s.swift_version = '4.2' s.ios.deployment_target = '9.0' end From e21a119005a9ee5df79846f89ba1ea63e015a5b5 Mon Sep 17 00:00:00 2001 From: Anton Averin Date: Thu, 21 Oct 2021 12:33:08 +0200 Subject: [PATCH 4/5] Revert "Fix optionals in location requests" This reverts commit a2afbbb6316dabae151e3c6915e9d72a751931cb. --- .../lib/src/method_channel_mapbox_gl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 55b8ba77c..e471f7d40 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -501,7 +501,7 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future requestMyLocationLatLng() async { try { - final Map reply = await _channel.invokeMethod( + final Map reply = await _channel.invokeMethod( 'locationComponent#getLastLocation', null); double latitude = 0.0, longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { From 8ed01ae707584d5df764636240e07e19d60129ed Mon Sep 17 00:00:00 2001 From: Anton Averin Date: Thu, 21 Oct 2021 12:33:15 +0200 Subject: [PATCH 5/5] Revert "Update iOS SDK" This reverts commit 7fd342b80dfd295bacd70fda53cce357e8e077a2. --- ios/mapbox_gl.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox_gl.podspec b/ios/mapbox_gl.podspec index a43a7f041..c4f46d333 100644 --- a/ios/mapbox_gl.podspec +++ b/ios/mapbox_gl.podspec @@ -16,7 +16,7 @@ A new Flutter plugin. s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.dependency 'MapboxAnnotationExtension', '~> 0.0.1-beta.1' - s.dependency 'Mapbox-iOS-SDK', '~> 6.4.0' + s.dependency 'Mapbox-iOS-SDK', '~> 6.3.0' s.swift_version = '4.2' s.ios.deployment_target = '9.0' end