From 7075c3bb0f84916d9471ebac9be39929a08ab73f Mon Sep 17 00:00:00 2001 From: Samderlust Date: Tue, 15 Mar 2022 05:40:17 -0400 Subject: [PATCH] add locationComponent#getLastLocation (#922) * add locationComponent#getLastLocation * format files * fixed formatting Co-authored-by: Felix Horvat --- ios/Classes/MapboxMapController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index f14c31863..f94466aa1 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -191,6 +191,15 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } else { result(nil) } + case "locationComponent#getLastLocation": + var reply = [String: NSObject]() + if let loc = mapView.userLocation?.location?.coordinate { + reply["latitude"] = loc.latitude as NSObject + reply["longitude"] = loc.longitude as NSObject + result(reply) + } else { + result(nil) + } case "map#setMapLanguage": guard let arguments = methodCall.arguments as? [String: Any] else { return } if let localIdentifier = arguments["language"] as? String, let style = mapView.style {