diff --git a/ios/RNMBX/CustomHttpHeaders.swift b/ios/RNMBX/CustomHttpHeaders.swift index 0bad4243c..d5cd7458f 100644 --- a/ios/RNMBX/CustomHttpHeaders.swift +++ b/ios/RNMBX/CustomHttpHeaders.swift @@ -10,7 +10,6 @@ struct CustomHttpHeadersMapValue { } class CustomHttpHeaders : HttpServiceInterceptorInterface { - #if RNMBX_11 func onRequest(for request: HttpRequest, continuation: @escaping HttpServiceInterceptorRequestContinuation) { let request = onRequest(for: request) continuation(HttpRequestOrResponse.fromHttpRequest(request)) @@ -19,7 +18,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface { func onResponse(for response: HttpResponse, continuation: @escaping HttpServiceInterceptorResponseContinuation) { continuation(response) } - #endif static var shared : CustomHttpHeaders = { let headers = CustomHttpHeaders() @@ -30,20 +28,11 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface { var customHeaders : [String:CustomHttpHeadersMapValue] = [:] func install() { - #if RNMBX_11 HttpServiceFactory.setHttpServiceInterceptorForInterceptor(self) - #else - HttpServiceFactory.getInstance().setInterceptorForInterceptor(self) - #endif } func reset() { - #if RNMBX_11 HttpServiceFactory.setHttpServiceInterceptorForInterceptor(nil) - #else - HttpServiceFactory.getInstance().setInterceptorForInterceptor(nil) - - #endif } // MARK: - HttpServiceInterceptorInterface @@ -76,14 +65,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface { return request } - #if !RNMBX_11 - func onDownload(forDownload download: DownloadOptions) -> DownloadOptions { - let customHeaders = getCustomRequestHeaders(for: download.request, with: customHeaders) - download.request.headers.merge(customHeaders) { (_, new) in new } - return download - } - #endif - func onResponse(for response: HttpResponse) -> HttpResponse { return response } diff --git a/ios/RNMBX/Offline/RNMBXOfflineModule.swift b/ios/RNMBX/Offline/RNMBXOfflineModule.swift index e65cc8c18..105309565 100644 --- a/ios/RNMBX/Offline/RNMBXOfflineModule.swift +++ b/ios/RNMBX/Offline/RNMBXOfflineModule.swift @@ -31,19 +31,11 @@ class RNMBXOfflineModule: RCTEventEmitter { } lazy var offlineManager : OfflineManager = { - #if RNMBX_11 return OfflineManager() - #else - return OfflineManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!)) - #endif }() - + lazy var offlineRegionManager: OfflineRegionManager = { - #if RNMBX_11 return OfflineRegionManager() - #else - return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!)) - #endif }() lazy var tileStore : TileStore = { @@ -363,7 +355,6 @@ class RNMBXOfflineModule: RCTEventEmitter { let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: pack.metadata)! - #if RNMBX_11 let threadedOfflineManager = OfflineManager() taskGroup.enter() let stylePackTask = threadedOfflineManager.loadStylePack(for: styleURI, loadOptions: stylePackLoadOptions) { progress in @@ -391,20 +382,6 @@ class RNMBXOfflineModule: RCTEventEmitter { ) let tilesetDescriptor = threadedOfflineManager.createTilesetDescriptor(for: descriptorOptions) let descriptors = [tilesetDescriptor] - #else - let descriptorOptions = TilesetDescriptorOptions( - styleURI: styleURI, - zoomRange: zoomRange, - stylePackOptions: stylePackLoadOptions - ) - let descriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions) - let tilesetDescriptorOptions = TilesetDescriptorOptionsForTilesets(tilesets: pack.tilesets, zoomRange: zoomRange) - let tilesetDescriptor = self.offlineManager.createTilesetDescriptorForTilesetDescriptorOptions(tilesetDescriptorOptions) - var descriptors = [descriptor] - if (!pack.tilesets.isEmpty) { - descriptors.append(tilesetDescriptor) - } - #endif let loadOptions = TileRegionLoadOptions( geometry: bounds, // RNMBXFeatureUtils.geometryToGeometry(bounds), @@ -452,11 +429,7 @@ class RNMBXOfflineModule: RCTEventEmitter { self.tileRegionPacks[id]!.state = downloadError ? .inactive : .complete } - #if RNMBX_11 self.tileRegionPacks[id]!.cancelables = [task, stylePackTask] - #else - self.tileRegionPacks[id]!.cancelables = [task] - #endif } func convertRegionsToJSON(regions: [TileRegion], resolve: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) { diff --git a/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift b/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift index 10efcbe05..661ec9594 100644 --- a/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift +++ b/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift @@ -6,11 +6,7 @@ class RNMBXOfflineModuleLegacy: RCTEventEmitter { final let CompleteRegionDownloadState = 2 lazy var offlineRegionManager: OfflineRegionManager = { - #if RNMBX_11 return OfflineRegionManager() - #else - return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!)) - #endif }() @objc diff --git a/ios/RNMBX/RNMBXAtmosphere.swift b/ios/RNMBX/RNMBXAtmosphere.swift index e423da2ab..ccbf448cc 100644 --- a/ios/RNMBX/RNMBXAtmosphere.swift +++ b/ios/RNMBX/RNMBXAtmosphere.swift @@ -1,8 +1,6 @@ import MapboxMaps -#if RNMBX_11 public typealias Style = StyleManager -#endif @objc(RNMBXAtmosphere) public class RNMBXAtmosphere : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer { diff --git a/ios/RNMBX/RNMBXBackgroundLayer.swift b/ios/RNMBX/RNMBXBackgroundLayer.swift index 2b1170c4d..43508bae8 100644 --- a/ios/RNMBX/RNMBXBackgroundLayer.swift +++ b/ios/RNMBX/RNMBXBackgroundLayer.swift @@ -6,10 +6,6 @@ public class RNMBXBackgroundLayer: RNMBXLayer { override func makeLayer(style: Style) throws -> Layer { var layer = LayerType(id: self.id!) - #if !RNMBX_11 - layer.sourceLayer = self.sourceLayerID - layer.source = sourceID - #endif return layer } diff --git a/ios/RNMBX/RNMBXCamera.swift b/ios/RNMBX/RNMBXCamera.swift index e51c8b663..085d0cae8 100644 --- a/ios/RNMBX/RNMBXCamera.swift +++ b/ios/RNMBX/RNMBXCamera.swift @@ -2,14 +2,12 @@ import Foundation import MapboxMaps import Turf -#if RNMBX_11 extension NSNumber { /// Converts an `NSNumber` to a `CGFloat` value from its `Double` representation. internal var CGFloat: CGFloat { CoreGraphics.CGFloat(doubleValue) } } -#endif public enum RemovalReason { case ViewRemoval, StyleChange, OnDestroy, ComponentChange, Reorder @@ -368,9 +366,6 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase { if let locationModule = RNMBXLocationModule.shared { locationModule.override(for: map.location) } - #if !RNMBX_11 - map.location.locationProvider.requestWhenInUseAuthorization() - #endif var trackingModeChanged = false var followOptions = FollowPuckViewportStateOptions() switch userTrackingMode { @@ -518,11 +513,7 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase { } withMapView { map in - #if RNMBX_11 let bounds = [sw, ne] - #else - let bounds = CoordinateBounds(southwest: sw, northeast: ne) - #endif camera = map.mapboxMap.camera( for: bounds, diff --git a/ios/RNMBX/RNMBXCameraGestureObserver.swift b/ios/RNMBX/RNMBXCameraGestureObserver.swift index 77e032857..355279a4b 100644 --- a/ios/RNMBX/RNMBXCameraGestureObserver.swift +++ b/ios/RNMBX/RNMBXCameraGestureObserver.swift @@ -25,9 +25,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe private var timeoutTimer: DispatchSourceTimer? = nil private var emittedForCurrentActivity: Bool = false - #if RNMBX_11 private var _cancelables = Set() - #endif private var quietMs: Double { (quietPeriodMs?.doubleValue) ?? 200.0 } private var maxMs: Double? { maxIntervalMs?.doubleValue } @@ -43,9 +41,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe switch gestureType { case .pan: return "pan" case .pinch: return "pinch" - #if RNMBX_11 case .rotation: return "rotate" - #endif case .pitch: return "pitch" default: return "\(gestureType)" } @@ -145,7 +141,6 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe guard hasOnMapSteady else { return } - #if RNMBX_11 let camera = map.mapView.camera! // Camera animator lifecycle @@ -175,14 +170,11 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe // Subscribe to gestures as a secondary observer (multicast from RNMBXMapView) map.addGestureDelegate(self) debugLog("addToMap and subscribed to gestures") - #endif } public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool { - #if RNMBX_11 _cancelables.forEach { $0.cancel() } _cancelables.removeAll() - #endif map.removeGestureDelegate(self) debugLog("removeFromMap and unsubscribed from gestures") cancelQuietTimer() diff --git a/ios/RNMBX/RNMBXCircleLayer.swift b/ios/RNMBX/RNMBXCircleLayer.swift index 857da61f3..e18a1ccde 100644 --- a/ios/RNMBX/RNMBXCircleLayer.swift +++ b/ios/RNMBX/RNMBXCircleLayer.swift @@ -7,11 +7,7 @@ public class RNMBXCircleLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let _ : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source: self.sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.sourceLayer = self.sourceLayerID layer.source = sourceID return layer @@ -26,7 +22,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout CircleLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -49,7 +44,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXCustomLocationProvider.swift b/ios/RNMBX/RNMBXCustomLocationProvider.swift index 59b8841e5..79187f4bb 100644 --- a/ios/RNMBX/RNMBXCustomLocationProvider.swift +++ b/ios/RNMBX/RNMBXCustomLocationProvider.swift @@ -42,10 +42,6 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapAndMapViewComponent { } var customLocationProvider: CustomLocationProvider? = nil - #if RNMBX_11 - #else - var defaultLocationProvider: LocationProvider? - #endif public func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) { self.map = map @@ -70,7 +66,6 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapAndMapViewComponent { // Uses default implementation from RNMBXMapComponentProtocol extension (returns false) } -#if RNMBX_11 // MARK: V11 location provider extension RNMBXCustomLocationProvider { func installCustomeLocationProviderIfNeeded(mapView: MapView) { @@ -81,19 +76,16 @@ extension RNMBXCustomLocationProvider { if (!coordinate.isEmpty) { applyCoordinate() } - + if let locationModule = RNMBXLocationModule.shared { locationModule.locationProvider = customLocationProvider locationModule.override(for: mapView.location) - //locationModule.locationProvider = customLocationProvider - // mapView.location.overrideLocationProvider(with: customLocationProvider!) } - - // customHeadingProvider = CustomHeadingProvider() + mapView.location.override(locationProvider: customLocationProvider, headingProvider: customLocationProvider) } } - + func removeCustomLocationProvider(mapView: MapView) { mapView.location.override(provider: AppleLocationProvider()) if let locationModule = RNMBXLocationModule.shared { @@ -101,62 +93,16 @@ extension RNMBXCustomLocationProvider { } customLocationProvider = nil } - - func updateCoordinate(latitude: Double, longitude: Double) { - customLocationProvider?.setLocation(latitude: NSNumber(floatLiteral: latitude), longitude: NSNumber(floatLiteral: longitude)) - } - - func updateHeading(heading: Double) { - customLocationProvider?.setHeading(heading: NSNumber(floatLiteral: heading)) - } -} -#else -// MARK: V10 location provider -extension RNMBXCustomLocationProvider { - func installCustomeLocationProviderIfNeeded(mapView: MapView) { - if (customLocationProvider == nil) { - if (defaultLocationProvider == nil) { - defaultLocationProvider = mapView.location.locationProvider - } - let customLocationProvider = CustomLocationProvider() - self.customLocationProvider = customLocationProvider - if let locationModule = RNMBXLocationModule.shared { - locationModule.locationProvider = customLocationProvider - locationModule.override(for: mapView.location) - } else { - Logger.error(TAG, "RNMBXLocationModule.shared is nil") - mapView.location.overrideLocationProvider(with: customLocationProvider) - } - - } - } - - func removeCustomLocationProvider(mapView: MapView) { - if let locationModule = RNMBXLocationModule.shared { - locationModule.resetLocationProvider() - locationModule.override(for: mapView.location) - } else if let provider = defaultLocationProvider { - mapView.location.overrideLocationProvider(with: provider) - } - customLocationProvider = nil - } - - func updareCoordinate(latitude: Double, longitude: Double) { - customLocationProvider?.setLocation(latitude: NSNumber(floatLiteral: latitude), longitude: NSNumber(floatLiteral: longitude)) - } - + func updateCoordinate(latitude: Double, longitude: Double) { customLocationProvider?.setLocation(latitude: NSNumber(floatLiteral: latitude), longitude: NSNumber(floatLiteral: longitude)) } - + func updateHeading(heading: Double) { customLocationProvider?.setHeading(heading: NSNumber(floatLiteral: heading)) } } -#endif - -#if RNMBX_11 class CustomLocationProvider: LocationProvider & HeadingProvider { // MARK: LocationProvider private var observers: NSHashTable = .weakObjects() @@ -182,7 +128,7 @@ class CustomLocationProvider: LocationProvider & HeadingProvider { (observer as? LocationObserver)?.onLocationUpdateReceived(for: [self.location!]) } } - + // MARK: HeadingProvider var latestHeading: Heading? private let headingObservers: NSHashTable = .weakObjects() @@ -194,7 +140,7 @@ class CustomLocationProvider: LocationProvider & HeadingProvider { func remove(headingObserver: HeadingObserver) { headingObservers.remove(headingObserver) } - + func setHeading(heading: NSNumber) { let latestHeading = Heading(direction: CLLocationDirection(truncating: heading), accuracy: CLLocationDirection(truncating: 1)) self.latestHeading = latestHeading @@ -203,80 +149,3 @@ class CustomLocationProvider: LocationProvider & HeadingProvider { } } } -#else -final public class CustomHeading: CLHeading { - private var _magneticHeading: CLLocationDirection = 0 - - public override var trueHeading: CLLocationDirection { - get { -1 } - } - - public override var magneticHeading: CLLocationDirection { - get { _magneticHeading } - set { _magneticHeading = newValue } - } -} - -class CustomLocationProvider: LocationProvider { - var locationProviderOptions: MapboxMaps.LocationOptions = .init() - - var authorizationStatus: CLAuthorizationStatus = .authorizedAlways - - var accuracyAuthorization: CLAccuracyAuthorization = .fullAccuracy - - var heading: CLHeading? - var location: CLLocation? - var updateLocation = false - var updateHeading = false - - var locationProviderDelegate: MapboxMaps.LocationProviderDelegate? - - func setDelegate(_ delegate: MapboxMaps.LocationProviderDelegate) { - locationProviderDelegate = delegate - } - - func setLocation(latitude: NSNumber, longitude: NSNumber) { - let lat = CLLocationDegrees(truncating: latitude) - let lon = CLLocationDegrees(truncating: longitude) - self.location = CLLocation(latitude: lat, longitude: lon) - if (updateLocation) { - locationProviderDelegate?.locationProvider(self, didUpdateLocations: [self.location!]) - } - } - - func setHeading(heading: NSNumber) { - let latestHeading = CustomHeading() - latestHeading.magneticHeading = CLLocationDirection(truncating: heading) - self.heading = latestHeading - if (self.updateHeading) { - locationProviderDelegate?.locationProvider(self, didUpdateHeading: self.heading!) - } - } - - func requestAlwaysAuthorization() { } - - func requestWhenInUseAuthorization() { } - - func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String) { } - - func startUpdatingLocation() { - self.updateLocation = true - } - - func stopUpdatingLocation() { - self.updateLocation = false - } - - var headingOrientation: CLDeviceOrientation = .unknown - - func startUpdatingHeading() { - self.updateHeading = true - } - - func stopUpdatingHeading() { - self.updateHeading = false - } - - func dismissHeadingCalibrationDisplay() { } -} -#endif diff --git a/ios/RNMBX/RNMBXFillExtrusionLayer.swift b/ios/RNMBX/RNMBXFillExtrusionLayer.swift index dd607f81b..9445615a9 100644 --- a/ios/RNMBX/RNMBXFillExtrusionLayer.swift +++ b/ios/RNMBX/RNMBXFillExtrusionLayer.swift @@ -6,11 +6,7 @@ public class RNMBXFillExtrusionLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let _ : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source:sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.sourceLayer = self.sourceLayerID layer.source = sourceID return layer @@ -24,7 +20,6 @@ public class RNMBXFillExtrusionLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout FillExtrusionLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -47,7 +42,6 @@ public class RNMBXFillExtrusionLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXFillLayer.swift b/ios/RNMBX/RNMBXFillLayer.swift index 1a59bbfed..fdfd65f8b 100644 --- a/ios/RNMBX/RNMBXFillLayer.swift +++ b/ios/RNMBX/RNMBXFillLayer.swift @@ -6,14 +6,10 @@ public class RNMBXFillLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let _ : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer: Layer = FillLayer(id: self.id!, source: sourceID!) - #else - var layer: Layer = FillLayer(id: self.id!) - #endif - + setOptions(&layer) - + return layer } @@ -25,7 +21,6 @@ public class RNMBXFillLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout FillLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -48,7 +43,6 @@ public class RNMBXFillLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXHeatmapLayer.swift b/ios/RNMBX/RNMBXHeatmapLayer.swift index d149db059..f82e122c5 100644 --- a/ios/RNMBX/RNMBXHeatmapLayer.swift +++ b/ios/RNMBX/RNMBXHeatmapLayer.swift @@ -6,13 +6,9 @@ public class RNMBXHeatmapLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let _ : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer: Layer = LayerType(id: self.id!, source: self.sourceID!) - #else - var layer: Layer = LayerType(id: self.id!) - #endif setOptions(&layer) - + return layer } diff --git a/ios/RNMBX/RNMBXImageSource.swift b/ios/RNMBX/RNMBXImageSource.swift index b60dee623..023b74534 100644 --- a/ios/RNMBX/RNMBXImageSource.swift +++ b/ios/RNMBX/RNMBXImageSource.swift @@ -35,11 +35,7 @@ public class RNMBXImageSource : RNMBXSource { override func makeSource() -> Source { - #if RNMBX_11 var result = ImageSource(id: self.id) - #else - var result = ImageSource() - #endif if let url = url { result.url = url } diff --git a/ios/RNMBX/RNMBXImages.swift b/ios/RNMBX/RNMBXImages.swift index c58549206..b89393de2 100644 --- a/ios/RNMBX/RNMBXImages.swift +++ b/ios/RNMBX/RNMBXImages.swift @@ -5,16 +5,10 @@ protocol RNMBXImageSetter : AnyObject { } func hasImage(style: Style, name: String) -> Bool { - #if RNMBX_11 return style.imageExists(withId: name) - #else - return (style.styleManager.getStyleImage(forImageId: name) != nil) - #endif } -#if RNMBX_11 typealias StyleImageMissingPayload = StyleImageMissing -#endif open class RNMBXImages : UIView, RNMBXMapComponent { diff --git a/ios/RNMBX/RNMBXLayer.swift b/ios/RNMBX/RNMBXLayer.swift index de37d2d67..62e065606 100644 --- a/ios/RNMBX/RNMBXLayer.swift +++ b/ios/RNMBX/RNMBXLayer.swift @@ -6,11 +6,7 @@ protocol RNMBXSourceConsumer : class { } func styleLayerExists(_ style: Style, id: String) -> Bool { - #if RNMBX_11 return style.layerExists(withId: id) - #else - return style.styleManager.styleLayerExists(forLayerId: id) - #endif } @objc(RNMBXLayer) @@ -258,7 +254,6 @@ public class RNMBXLayer : UIView, RNMBXMapComponent, RNMBXSourceConsumer { removeFromMap(style) } - #if RNMBX_11 func _toSlot(_ slot: String) -> Slot? { switch slot { case "top": @@ -271,7 +266,6 @@ public class RNMBXLayer : UIView, RNMBXMapComponent, RNMBXSourceConsumer { return Slot(rawValue: slot); } } - #endif func setBaseOptions(_ layer: inout T) { if let minZoom = minZoomLevel { @@ -282,36 +276,13 @@ public class RNMBXLayer : UIView, RNMBXMapComponent, RNMBXSourceConsumer { layer.maxZoom = maxZoom.doubleValue } - #if RNMBX_11 if let slot = slot { layer.slot = _toSlot(slot) } - #endif } func setOptions(_ layer: inout Layer) { setBaseOptions(&layer) - #if !RNMBX_11 - if let sourceLayerID = sourceLayerID { - layer.sourceLayer = sourceLayerID - } - - if let sourceID = sourceID { - if !(existingLayer && sourceID == DEFAULT_SOURCE_ID) && hasSource() { - layer.source = sourceID - } - } - - if let filter = filter, filter.count > 0 { - do { - let data = try JSONSerialization.data(withJSONObject: filter, options: .prettyPrinted) - let decodedExpression = try JSONDecoder().decode(Expression.self, from: data) - layer.filter = decodedExpression - } catch { - Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") - } - } - #endif } private func optionsChanged() { @@ -381,14 +352,8 @@ public class RNMBXLayer : UIView, RNMBXMapComponent, RNMBXSourceConsumer { } } -#if RNMBX_11 protocol LayerWithSource : Layer { var source: String? { get set } var sourceLayer: String? { get set } var filter: MapboxMaps.Expression? { get set} } -#else -protocol LayerWithSource : Layer { - -} -#endif diff --git a/ios/RNMBX/RNMBXLight.swift b/ios/RNMBX/RNMBXLight.swift index aab3f9f64..9ad117126 100644 --- a/ios/RNMBX/RNMBXLight.swift +++ b/ios/RNMBX/RNMBXLight.swift @@ -1,8 +1,6 @@ import MapboxMaps -#if RNMBX_11 typealias Light = FlatLight -#endif @objc(RNMBXLight) public class RNMBXLight: UIView, RNMBXMapComponent { @@ -21,14 +19,8 @@ public class RNMBXLight: UIView, RNMBXMapComponent { } func apply(light: Light) { - let lightData = try! JSONEncoder().encode(light) - let lightDictionary = try! JSONSerialization.jsonObject(with: lightData) logged("RNMBXLight.apply") { -#if RNMBX_11 try self.map.setLights(light) -#else - try! self.map.style.setLight(properties: lightDictionary as! [String:Any]) -#endif } } diff --git a/ios/RNMBX/RNMBXLineLayer.swift b/ios/RNMBX/RNMBXLineLayer.swift index 742cbfb45..4ead3bab5 100644 --- a/ios/RNMBX/RNMBXLineLayer.swift +++ b/ios/RNMBX/RNMBXLineLayer.swift @@ -6,11 +6,7 @@ public class RNMBXLineLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let vectorSource : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source: sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.sourceLayer = self.sourceLayerID layer.source = sourceID return layer @@ -24,7 +20,6 @@ public class RNMBXLineLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout LineLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -47,7 +42,6 @@ public class RNMBXLineLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXLocationModule.swift b/ios/RNMBX/RNMBXLocationModule.swift index 9ab203a12..df4572934 100644 --- a/ios/RNMBX/RNMBXLocationModule.swift +++ b/ios/RNMBX/RNMBXLocationModule.swift @@ -1,436 +1,110 @@ -import Foundation import MapboxMaps -#if !RNMBX_11 +let RCT_MAPBOX_USER_LOCATION_UPDATE = "MapboxUserLocationUpdate"; @objc(RNMBXLocation) class RNMBXLocation: NSObject { - var location : CLLocation = CLLocation(latitude: 0.0, longitude: 0.0) + var location : Location? = nil - var heading : CLHeading? = nil + var heading : Heading? = nil var timestamp: Date? = nil - func toJSON() -> NSDictionary { - return [ - "coords": [ - "longitude": location.coordinate.longitude, + func toJSON() -> [String:Any] { + var coords: [String:Any] = [:] + + if let location = location { + coords = coords.merging([ "latitude": location.coordinate.latitude, + "longitude": location.coordinate.longitude, "altitude": location.altitude, "accuracy": location.horizontalAccuracy, - "heading": heading?.trueHeading ?? 0.0, - "course": location.course, - "speed": location.speed, - ], - "timestamp": (timestamp ?? location.timestamp).timeIntervalSince1970 * 1000 - ] - } -} - -typealias RNMBXLocationBlock = (RNMBXLocation?) -> Void - -let RCT_MAPBOX_USER_LOCATION_UPDATE = "MapboxUserLocationUpdate"; - -/// This implementation of LocationProviderDelegate is used by `LocationManager` to work around -/// the fact that the `LocationProvider` API does not allow the delegate to be set to `nil`. -internal class EmptyLocationProviderDelegate: LocationProviderDelegate { - func locationProvider(_ provider: LocationProvider, didFailWithError error: Error) {} - func locationProvider(_ provider: LocationProvider, didUpdateHeading newHeading: CLHeading) {} - func locationProvider(_ provider: LocationProvider, didUpdateLocations locations: [CLLocation]) {} - func locationProviderDidChangeAuthorization(_ provider: LocationProvider) {} -} - -protocol LocationProviderRNMBXDelegate : AnyObject { - func locationManager(_ locationManager: LocationProviderRNMBX, didUpdateLocation: RNMBXLocation) -} - -class RNMBXAppleLocationProvider: NSObject { - private var locationProvider: CLLocationManager - - private var privateLocationProviderOptions: LocationOptions { - didSet { - locationProvider.distanceFilter = privateLocationProviderOptions.distanceFilter - locationProvider.desiredAccuracy = privateLocationProviderOptions.desiredAccuracy - locationProvider.activityType = privateLocationProviderOptions.activityType - } - } - private weak var delegate: LocationProviderDelegate? - - public var headingOrientation: CLDeviceOrientation { - didSet { locationProvider.headingOrientation = headingOrientation } + "course": location.bearing, + "speed": location.speed + ]) { (_, new ) in new } } - - public override init() { - locationProvider = CLLocationManager() - privateLocationProviderOptions = LocationOptions() - headingOrientation = locationProvider.headingOrientation - super.init() - locationProvider.delegate = self - } -} - -extension RNMBXAppleLocationProvider: LocationProvider { - public var locationProviderOptions: LocationOptions { - get { privateLocationProviderOptions } - set { privateLocationProviderOptions = newValue } + if let heading = heading { + coords = coords.merging([ + "heading": heading.direction + ]) { (_, new) in new } } - - public var authorizationStatus: CLAuthorizationStatus { - if #available(iOS 14.0, *) { - return locationProvider.authorizationStatus - } else { - return CLLocationManager.authorizationStatus() - } - } - - public var accuracyAuthorization: CLAccuracyAuthorization { - if #available(iOS 14.0, *) { - return locationProvider.accuracyAuthorization - } else { - return .fullAccuracy - } - } - - public var heading: CLHeading? { - return locationProvider.heading - } - - public func setDelegate(_ delegate: LocationProviderDelegate) { - self.delegate = delegate - } - - public func requestAlwaysAuthorization() { - locationProvider.requestAlwaysAuthorization() - } - - public func requestWhenInUseAuthorization() { - locationProvider.requestWhenInUseAuthorization() - } - - @available(iOS 14.0, *) - public func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String) { - locationProvider.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey) - } - - public func startUpdatingLocation() { - locationProvider.startUpdatingLocation() - } - - public func stopUpdatingLocation() { - locationProvider.stopUpdatingLocation() - } - - public func startUpdatingHeading() { - locationProvider.startUpdatingHeading() - } - - public func stopUpdatingHeading() { - locationProvider.stopUpdatingHeading() - } - - public func dismissHeadingCalibrationDisplay() { - locationProvider.dismissHeadingCalibrationDisplay() - } -} - -extension RNMBXAppleLocationProvider: CLLocationManagerDelegate { - public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - delegate?.locationProvider(self, didUpdateLocations: locations) - } - - public func locationManager(_ manager: CLLocationManager, didUpdateHeading heading: CLHeading) { - delegate?.locationProvider(self, didUpdateHeading: heading) - } - - public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { - delegate?.locationProvider(self, didFailWithError: error) - } - - @available(iOS 14.0, *) - public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { - delegate?.locationProviderDidChangeAuthorization(self) - } - - public func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool { - guard let calibratingDelegate = delegate as? CalibratingLocationProviderDelegate else { - return false - } - - return calibratingDelegate.locationProviderShouldDisplayHeadingCalibration(self) + + return [ + "coords": coords, + "timestamp": (timestamp ?? location?.timestamp ?? heading?.timestamp ?? Date()).timeIntervalSince1970 * 1000 + ] } } -internal protocol CalibratingLocationProviderDelegate: LocationProviderDelegate { - func locationProviderShouldDisplayHeadingCalibration(_ locationProvider: LocationProvider) -> Bool -} - -/// LocationProviderRNMBX listens to updates from a locationProvider and implements the LocationProvider interface itself -/// So it can be source of Mapbox locationProduces (which updates location pluck and viewport if configured) as well as source to updates -/// to RNMBXLocationModules. -class LocationProviderRNMBX : LocationProviderDelegate { - enum LocationUpdateType { - case heading - case location - } - - var provider: LocationProvider - - var lastKnownLocation : CLLocation? - var lastKnownHeading : CLHeading? - var shouldRequestAlwaysAuthorization: Bool? - - weak var delegate: LocationProviderRNMBXDelegate? - weak var locationProviderDelage: LocationProviderDelegate? +/* +class RNMBXAppleLocationProviderProxy : LocationProvider & HeadingProvider { + var origProvider : AppleLocationProvider var headingSimulator: Timer? = nil var simulatedHeading: Double = 0.0 var simulatedHeadingIncrement: Double = 1.0 - - struct Status { - var provider = (updatingLocation: false, updatingHeading: false) - var RNMBXModule = false - - var shouldUpdateLocation: Bool { - return provider.updatingLocation || RNMBXModule - } - var shouldUpdateHeading: Bool { - return provider.updatingHeading || RNMBXModule - } - } - - var started = Status(provider: (updatingLocation: false, updatingHeading: false), RNMBXModule: false) { - didSet { - _syncStarted(oldValue: oldValue, started: started) - } - } - - init() { - provider = RNMBXAppleLocationProvider() - provider.setDelegate(self) - } - - func setDistanceFilter(_ distanceFilter: CLLocationDistance) { - var options = provider.locationProviderOptions - options.distanceFilter = distanceFilter - provider.locationProviderOptions = options - } - - func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) { - shouldRequestAlwaysAuthorization = requestsAlwaysUse; - } - - func start() { - if shouldRequestAlwaysAuthorization == true { - provider.requestAlwaysAuthorization() - } - provider.requestWhenInUseAuthorization() - started.RNMBXModule = true - } - - func stop() { - started.RNMBXModule = false - } - - func _syncStarted(oldValue: Status, started: Status) { - var stoppedSomething = false - if (oldValue.shouldUpdateLocation != started.shouldUpdateLocation) { - if started.shouldUpdateLocation { - provider.setDelegate(self) - provider.startUpdatingLocation() - } else { - provider.stopUpdatingLocation() - stoppedSomething = true - } - } - - if (oldValue.shouldUpdateHeading != started.shouldUpdateHeading) { - if started.shouldUpdateHeading { - provider.setDelegate(self) - provider.startUpdatingHeading() - } else { - provider.stopUpdatingHeading() - stoppedSomething = true - } - } - - if stoppedSomething && !started.shouldUpdateLocation && !started.shouldUpdateHeading { - provider.setDelegate(EmptyLocationProviderDelegate()) - } - } - - func _convertToMapboxLocation(_ location: CLLocation?, type: LocationUpdateType) -> RNMBXLocation { - guard let location = location else { - return RNMBXLocation() - } - - let userLocation = RNMBXLocation() - userLocation.location = location; - userLocation.heading = lastKnownHeading - switch type { - case .location: - userLocation.timestamp = location.timestamp - case .heading: - userLocation.timestamp = lastKnownHeading!.timestamp - } - return userLocation; - } - - func _updateDelegate(type: LocationUpdateType) { - if delegate == nil { - return; - } - - let userLocation = _convertToMapboxLocation(lastKnownLocation, type: type) - - delegate?.locationManager(self, didUpdateLocation: userLocation) - } - - // MARK: - LocationProviderDelegate - - func locationProvider(_ provider: LocationProvider, didUpdateLocations locations: [CLLocation]) { - lastKnownLocation = locations.last - self._updateDelegate(type: .location) - - locationProviderDelage?.locationProvider(provider, didUpdateLocations: locations) - } - - func locationProvider(_ provider: LocationProvider, didUpdateHeading newHeading: CLHeading) { - lastKnownHeading = newHeading - self._updateDelegate(type: .heading) - - locationProviderDelage?.locationProvider(provider, didUpdateHeading: newHeading) - } - - func locationProvider(_ provider: LocationProvider, didFailWithError error: Error) { - locationProviderDelage?.locationProvider(provider, didFailWithError: error) - } - - func locationProviderDidChangeAuthorization(_ provider: LocationProvider) { - locationProviderDelage?.locationProviderDidChangeAuthorization(provider) - } -} - -// MARK: LocationProvider - -extension LocationProviderRNMBX: LocationProvider { - var locationProviderOptions: LocationOptions { + public var options: AppleLocationProvider.Options { get { - provider.locationProviderOptions + origProvider.options } - set(newValue) { - provider.locationProviderOptions = newValue + set { + origProvider.options = newValue } } - var authorizationStatus: CLAuthorizationStatus { + var onLocationUpdate: Signal<[Location]> { get { - provider.authorizationStatus + origProvider.onLocationUpdate } } - var accuracyAuthorization: CLAccuracyAuthorization { + var onHeadingUpdate: Signal { get { - provider.accuracyAuthorization + origProvider.onHeadingUpdate } } - var heading: CLHeading? { - get { - provider.heading - } + init(provider: AppleLocationProvider) { + self.origProvider = provider } - func setDelegate(_ delegate: LocationProviderDelegate) { - provider.setDelegate(self) - locationProviderDelage = delegate - - if let lastLocation = lastKnownLocation { - DispatchQueue.main.async { - self.locationProviderDelage?.locationProvider(self, didUpdateLocations: [lastLocation]) - } - } - if let lastHeading = lastKnownHeading { - DispatchQueue.main.async { [self] in - self.locationProviderDelage?.locationProvider(self, didUpdateHeading: lastHeading) - } - } + func addLocationObserver(for observer: LocationObserver) { + origProvider.addLocationObserver(for: observer) } - func requestAlwaysAuthorization() { - provider.requestAlwaysAuthorization() + func removeLocationObserver(for observer: LocationObserver) { + origProvider.removeLocationObserver(for: observer) } - func requestWhenInUseAuthorization() { - provider.requestWhenInUseAuthorization() + func getLastObservedLocation() -> Location? { + origProvider.getLastObservedLocation() } - func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String) { - if #available(iOS 14.0, *) { - provider.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey) - } else { - // Fallback on earlier versions + var latestHeading: MapboxMaps.Heading? { + get { + return origProvider.latestHeading } } - func startUpdatingLocation() { - started.provider.updatingLocation = true - } - - func stopUpdatingLocation() { - started.provider.updatingLocation = false - } - - var headingOrientation: CLDeviceOrientation { + var latestLocation: MapboxMaps.Location? { get { - return provider.headingOrientation - } - set(newValue) { - provider.headingOrientation = newValue + return origProvider.latestLocation } } - func startUpdatingHeading() { - started.provider.updatingHeading = true + func add(headingObserver: MapboxMaps.HeadingObserver) { + origProvider.add(headingObserver: headingObserver) } - func stopUpdatingHeading() { - started.provider.updatingHeading = false - } - - func dismissHeadingCalibrationDisplay() { - provider.dismissHeadingCalibrationDisplay() + func remove(headingObserver: MapboxMaps.HeadingObserver) { + origProvider.remove(headingObserver: headingObserver) } } -// MARK: heading simulation - -final public class SimulatedHeading: CLHeading { - init(trueHeading: CLLocationDirection, timestamp: Date) { - _trueHeading = trueHeading - _timestamp = timestamp - super.init() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private var _trueHeading: CLLocationDirection = 0 - private var _timestamp: Date - - public override var trueHeading: CLLocationDirection { - get { _trueHeading } - set { _trueHeading = newValue } - } - - public override var timestamp: Date{ - get { _timestamp } - set { _timestamp = newValue } - } -} +// MARK: - heading simulation -extension LocationProviderRNMBX { +extension RNMBXAppleLocationProviderProxy { func simulateHeading(changesPerSecond: Int, increment: Double) { self.simulatedHeadingIncrement = increment DispatchQueue.main.async { @@ -450,102 +124,164 @@ extension LocationProviderRNMBX { } } } +*/ -// LocationModule is a sigleton class -@objc(RNMBXLocationModule) -class RNMBXLocationModule: RCTEventEmitter, LocationProviderRNMBXDelegate { +// MARK: - RNMBXLocationModule +@objc(RNMBXLocationModule) +class RNMBXLocationModule: RCTEventEmitter { static weak var shared : RNMBXLocationModule? = nil + + var _locationProvider : LocationProvider & HeadingProvider = AppleLocationProvider() + var locationUpdateObserver : Cancelable? = nil + var locationHeadingObserver : Cancelable? = nil + + var actLocation : RNMBXLocation = RNMBXLocation() + + var hasListener : Bool = false - var hasListener = false - - var locationProvider : LocationProvider - var defaultLocationProvider : LocationProvider? = nil - - var locationEventThrottle : ( - waitBetweenEvents: Double?, - lastSentTimestamp: Double? - ) = ( - nil, - nil - ) + var throttler = EventThrottler() override init() { - locationProvider = LocationProviderRNMBX() - defaultLocationProvider = locationProvider super.init() - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.delegate = self - } RNMBXLocationModule.shared = self } + func override(for locationManager: LocationManager) { + locationManager.override(provider: _locationProvider) + } + @objc override static func requiresMainQueueSetup() -> Bool { return true } - @objc - override func constantsToExport() -> [AnyHashable: Any]! { - return [:]; - } - @objc override func supportedEvents() -> [String] { return [RCT_MAPBOX_USER_LOCATION_UPDATE]; } @objc func start(_ minDisplacement: CLLocationDistance) { - if minDisplacement >= 0.0 { - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.setDistanceFilter(minDisplacement) + setMinDisplacement(minDisplacement) + + locationUpdateObserver?.cancel() + locationUpdateObserver = observeLocationUpdates(_locationProvider) { location in + guard self.hasListener else { return } + + self.actLocation.location = location.last + self.throttler.perform { + self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: self.actLocation.toJSON()) } } - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.start() + locationHeadingObserver?.cancel() + locationHeadingObserver = observeHeadingUpdates(_locationProvider) { heading in + guard self.hasListener else { return } + + self.actLocation.heading = heading + self.throttler.perform { + self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: self.actLocation.toJSON()) + } } } - @objc func stop() { - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.stop() + class _LocationObserver : Cancelable, LocationObserver { + weak var locationProvider: LocationProvider? + var callback: (([Location]) -> Void)? + + init(_ locationProvider: LocationProvider) { + self.locationProvider = locationProvider + } + + func onLocationUpdateReceived(for locations: [Location]) { + callback?(locations) + } + + func cancel() { + locationProvider?.removeLocationObserver(for: self) + locationProvider = nil + } + + deinit { + self.cancel() } } - @objc func getLastKnownLocation() -> NSDictionary? { - let result = RNMBXLocation() - if let locationProvider = locationProvider as? LocationProviderRNMBX { - if let location = locationProvider.lastKnownLocation { - result.location = location - result.timestamp = location.timestamp - } - if let heading = locationProvider.lastKnownHeading { - result.heading = heading - if result.timestamp == nil || - heading.timestamp.compare(result.timestamp!) == .orderedAscending { - result.timestamp = heading.timestamp - } - } + class _HeadingObserver: Cancelable, HeadingObserver { + var headingProvider: HeadingProvider? + var callback: ((Heading) -> Void)? + + init(_ headingProvider: HeadingProvider) { + self.headingProvider = headingProvider + } + + func onHeadingUpdate(_ heading: MapboxMaps.Heading) { + callback?(heading) + } + + func cancel() { + headingProvider?.remove(headingObserver: self) + headingProvider = nil + } + + deinit { + self.cancel() } - return result.toJSON() } - @objc func setMinDisplacement(_ minDisplacement: CLLocationDistance) { - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.setDistanceFilter(minDisplacement) + func observeLocationUpdates(_ locationProvider: LocationProvider, callback: @escaping ([Location]) -> Void) -> Cancelable { + let observer = _LocationObserver(locationProvider) + observer.callback = callback + locationProvider.addLocationObserver(for: observer) + return observer + } + + func observeHeadingUpdates(_ headingProvider: HeadingProvider, callback: @escaping (Heading) -> Void) -> Cancelable { + let observer = _HeadingObserver(headingProvider) + observer.callback = callback + headingProvider.add(headingObserver: observer) + return observer + } + + @objc func stop() { + locationUpdateObserver?.cancel() + locationUpdateObserver = nil + locationHeadingObserver?.cancel() + locationHeadingObserver = nil + throttler.cancel() + } + + @objc func getLastKnownLocation() -> [String: Any]? { + let last = RNMBXLocation() + last.heading = _locationProvider.latestHeading + last.location = _locationProvider.getLastObservedLocation() + return last.toJSON() + } + + @objc + func setMinDisplacement(_ minDisplacement: CLLocationDistance) { + if let appleLocationProvider = _locationProvider as? AppleLocationProvider { + var newOptions = appleLocationProvider.options + newOptions.distanceFilter = minDisplacement + if minDisplacement >= 0.0 { appleLocationProvider.options = newOptions } + } + } + + @objc + func setLocationEventThrottle(_ throttleValue:NSNumber) { + let throttleValue = throttleValue.doubleValue + if throttleValue > 0.0 { + throttler.waitBetweenEvents = throttleValue + } else { + throttler.waitBetweenEvents = nil } } @objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) { - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.setRequestsAlwaysUse(requestsAlwaysUse) - } + // V11TODO } @objc func simulateHeading(_ changesPerSecond: NSNumber, increment: NSNumber) { - if let locationProvider = locationProvider as? LocationProviderRNMBX { - locationProvider.simulateHeading(changesPerSecond: changesPerSecond.intValue, increment: increment.doubleValue) - } + // V11TODO } @objc @@ -557,70 +293,59 @@ class RNMBXLocationModule: RCTEventEmitter, LocationProviderRNMBXDelegate { @objc override func stopObserving() { super.stopObserving() + throttler.cancel() hasListener = false } - - func locationManager(_ locationManager: LocationProviderRNMBX, didUpdateLocation location: RNMBXLocation) { - guard hasListener, let _ = bridge else { - return - } - if shouldSendLocationEvent() { - self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: location.toJSON()) + var locationProvider : LocationProvider & HeadingProvider { + get { + return _locationProvider } - } - - func override(for locationManager: LocationManager) { - if let locationModule = RNMBXLocationModule.shared { - var isSameProvider = false - if let currentProvider = locationManager.locationProvider as? AnyObject, let newProvider = locationModule.locationProvider as? AnyObject { - if currentProvider === newProvider { - isSameProvider = true - } - } - if !isSameProvider { - locationManager.overrideLocationProvider(with: locationModule.locationProvider) - } + set(value) { + _locationProvider = value } } - func resetLocationProvider() { - if let defaultLocationProvider = defaultLocationProvider { - self.locationProvider = defaultLocationProvider - } - } - - // MARK: - location event throttle - @objc - func setLocationEventThrottle(_ throttleValue:NSNumber) { - let throttleValue = throttleValue.doubleValue - if throttleValue > 0.0 { - locationEventThrottle.waitBetweenEvents = throttleValue - } else { - locationEventThrottle.waitBetweenEvents = nil - } + func overrideLocationProvider(newProvider: LocationProvider & HeadingProvider) { + _locationProvider = newProvider } + + +} - func shouldSendLocationEvent() -> Bool { - guard let waitBetweenEvents = locationEventThrottle.waitBetweenEvents, waitBetweenEvents > 0 else { +class EventThrottler { + var waitBetweenEvents: Double? = nil + var lastSentTimestamp: Double? = nil + + func shouldSend() -> Bool { + guard let waitBetweenEvents = waitBetweenEvents, waitBetweenEvents > 0 else { return true } let currentTimestamp: Double = CACurrentMediaTime() * 1000.0 - guard let lastSentTimestamp = locationEventThrottle.lastSentTimestamp else { - locationEventThrottle.lastSentTimestamp = currentTimestamp + guard let lastSentTimestamp = lastSentTimestamp else { + self.lastSentTimestamp = currentTimestamp return true; } if (currentTimestamp - lastSentTimestamp > waitBetweenEvents) { - locationEventThrottle.lastSentTimestamp = currentTimestamp + self.lastSentTimestamp = currentTimestamp return true; } return false; } + + func cancel() {} + + func shouldTrhottle() -> Bool { + return !shouldSend() + } + + func perform(action: @escaping () -> Void) { + if shouldSend() { + action() + } + } } - -#endif - diff --git a/ios/RNMBX/RNMBXLocationModuleV11.swift b/ios/RNMBX/RNMBXLocationModuleV11.swift deleted file mode 100644 index 55a821240..000000000 --- a/ios/RNMBX/RNMBXLocationModuleV11.swift +++ /dev/null @@ -1,353 +0,0 @@ -#if RNMBX_11 -import MapboxMaps - -let RCT_MAPBOX_USER_LOCATION_UPDATE = "MapboxUserLocationUpdate"; - -@objc(RNMBXLocation) -class RNMBXLocation: NSObject { - var location : Location? = nil - - var heading : Heading? = nil - - var timestamp: Date? = nil - - func toJSON() -> [String:Any] { - var coords: [String:Any] = [:] - - if let location = location { - coords = coords.merging([ - "latitude": location.coordinate.latitude, - "longitude": location.coordinate.longitude, - "altitude": location.altitude, - "accuracy": location.horizontalAccuracy, - "course": location.bearing, - "speed": location.speed - ]) { (_, new ) in new } - } - if let heading = heading { - coords = coords.merging([ - "heading": heading.direction - ]) { (_, new) in new } - } - - return [ - "coords": coords, - "timestamp": (timestamp ?? location?.timestamp ?? heading?.timestamp ?? Date()).timeIntervalSince1970 * 1000 - ] - } -} - -/* -class RNMBXAppleLocationProviderProxy : LocationProvider & HeadingProvider { - var origProvider : AppleLocationProvider - - var headingSimulator: Timer? = nil - var simulatedHeading: Double = 0.0 - var simulatedHeadingIncrement: Double = 1.0 - - public var options: AppleLocationProvider.Options { - get { - origProvider.options - } - set { - origProvider.options = newValue - } - } - - var onLocationUpdate: Signal<[Location]> { - get { - origProvider.onLocationUpdate - } - } - - var onHeadingUpdate: Signal { - get { - origProvider.onHeadingUpdate - } - } - - init(provider: AppleLocationProvider) { - self.origProvider = provider - } - - func addLocationObserver(for observer: LocationObserver) { - origProvider.addLocationObserver(for: observer) - } - - func removeLocationObserver(for observer: LocationObserver) { - origProvider.removeLocationObserver(for: observer) - } - - func getLastObservedLocation() -> Location? { - origProvider.getLastObservedLocation() - } - - var latestHeading: MapboxMaps.Heading? { - get { - return origProvider.latestHeading - } - } - - var latestLocation: MapboxMaps.Location? { - get { - return origProvider.latestLocation - } - } - - func add(headingObserver: MapboxMaps.HeadingObserver) { - origProvider.add(headingObserver: headingObserver) - } - - func remove(headingObserver: MapboxMaps.HeadingObserver) { - origProvider.remove(headingObserver: headingObserver) - } -} - -// MARK: - heading simulation - -extension RNMBXAppleLocationProviderProxy { - func simulateHeading(changesPerSecond: Int, increment: Double) { - self.simulatedHeadingIncrement = increment - DispatchQueue.main.async { - if let headingSimulator = self.headingSimulator { - headingSimulator.invalidate() - } - self.headingSimulator = nil - - if (changesPerSecond > 0) { - self.headingSimulator = Timer.scheduledTimer(withTimeInterval: 1.0/Double(changesPerSecond), repeats: true) { [weak self] (_) in - guard let self = self else { return } - - self.simulatedHeading = (self.simulatedHeading + self.simulatedHeadingIncrement).truncatingRemainder(dividingBy: 360.0) - self.locationProvider(self.provider, didUpdateHeading: SimulatedHeading(trueHeading: self.simulatedHeading, timestamp: Date()) ) - } - } - } - } -} -*/ - -// MARK: - RNMBXLocationModule - -@objc(RNMBXLocationModule) -class RNMBXLocationModule: RCTEventEmitter { - static weak var shared : RNMBXLocationModule? = nil - - var _locationProvider : LocationProvider & HeadingProvider = AppleLocationProvider() - var locationUpdateObserver : Cancelable? = nil - var locationHeadingObserver : Cancelable? = nil - - var actLocation : RNMBXLocation = RNMBXLocation() - - var hasListener : Bool = false - - var throttler = EventThrottler() - - override init() { - super.init() - RNMBXLocationModule.shared = self - } - - func override(for locationManager: LocationManager) { - locationManager.override(provider: _locationProvider) - } - - @objc - override static func requiresMainQueueSetup() -> Bool { - return true - } - - @objc override func supportedEvents() -> [String] - { - return [RCT_MAPBOX_USER_LOCATION_UPDATE]; - } - - @objc func start(_ minDisplacement: CLLocationDistance) { - setMinDisplacement(minDisplacement) - - locationUpdateObserver?.cancel() - locationUpdateObserver = observeLocationUpdates(_locationProvider) { location in - guard self.hasListener else { return } - - self.actLocation.location = location.last - self.throttler.perform { - self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: self.actLocation.toJSON()) - } - } - locationHeadingObserver?.cancel() - locationHeadingObserver = observeHeadingUpdates(_locationProvider) { heading in - guard self.hasListener else { return } - - self.actLocation.heading = heading - self.throttler.perform { - self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: self.actLocation.toJSON()) - } - } - } - - class _LocationObserver : Cancelable, LocationObserver { - weak var locationProvider: LocationProvider? - var callback: (([Location]) -> Void)? - - init(_ locationProvider: LocationProvider) { - self.locationProvider = locationProvider - } - - func onLocationUpdateReceived(for locations: [Location]) { - callback?(locations) - } - - func cancel() { - locationProvider?.removeLocationObserver(for: self) - locationProvider = nil - } - - deinit { - self.cancel() - } - } - - class _HeadingObserver: Cancelable, HeadingObserver { - var headingProvider: HeadingProvider? - var callback: ((Heading) -> Void)? - - init(_ headingProvider: HeadingProvider) { - self.headingProvider = headingProvider - } - - func onHeadingUpdate(_ heading: MapboxMaps.Heading) { - callback?(heading) - } - - func cancel() { - headingProvider?.remove(headingObserver: self) - headingProvider = nil - } - - deinit { - self.cancel() - } - } - - func observeLocationUpdates(_ locationProvider: LocationProvider, callback: @escaping ([Location]) -> Void) -> Cancelable { - let observer = _LocationObserver(locationProvider) - observer.callback = callback - locationProvider.addLocationObserver(for: observer) - return observer - } - - func observeHeadingUpdates(_ headingProvider: HeadingProvider, callback: @escaping (Heading) -> Void) -> Cancelable { - let observer = _HeadingObserver(headingProvider) - observer.callback = callback - headingProvider.add(headingObserver: observer) - return observer - } - - @objc func stop() { - locationUpdateObserver?.cancel() - locationUpdateObserver = nil - locationHeadingObserver?.cancel() - locationHeadingObserver = nil - throttler.cancel() - } - - @objc func getLastKnownLocation() -> [String: Any]? { - let last = RNMBXLocation() - last.heading = _locationProvider.latestHeading - last.location = _locationProvider.getLastObservedLocation() - return last.toJSON() - } - - @objc - func setMinDisplacement(_ minDisplacement: CLLocationDistance) { - if let appleLocationProvider = _locationProvider as? AppleLocationProvider { - var newOptions = appleLocationProvider.options - newOptions.distanceFilter = minDisplacement - if minDisplacement >= 0.0 { appleLocationProvider.options = newOptions } - } - } - - @objc - func setLocationEventThrottle(_ throttleValue:NSNumber) { - let throttleValue = throttleValue.doubleValue - if throttleValue > 0.0 { - throttler.waitBetweenEvents = throttleValue - } else { - throttler.waitBetweenEvents = nil - } - } - - @objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) { - // V11TODO - } - - @objc func simulateHeading(_ changesPerSecond: NSNumber, increment: NSNumber) { - // V11TODO - } - - @objc - override func startObserving() { - super.startObserving() - hasListener = true - } - - @objc - override func stopObserving() { - super.stopObserving() - throttler.cancel() - hasListener = false - } - - var locationProvider : LocationProvider & HeadingProvider { - get { - return _locationProvider - } - set(value) { - _locationProvider = value - } - } - - func overrideLocationProvider(newProvider: LocationProvider & HeadingProvider) { - _locationProvider = newProvider - } - - -} - -class EventThrottler { - var waitBetweenEvents: Double? = nil - var lastSentTimestamp: Double? = nil - - func shouldSend() -> Bool { - guard let waitBetweenEvents = waitBetweenEvents, waitBetweenEvents > 0 else { - return true - } - - let currentTimestamp: Double = CACurrentMediaTime() * 1000.0 - - guard let lastSentTimestamp = lastSentTimestamp else { - self.lastSentTimestamp = currentTimestamp - return true; - } - - if (currentTimestamp - lastSentTimestamp > waitBetweenEvents) { - self.lastSentTimestamp = currentTimestamp - return true; - } - - return false; - } - - func cancel() {} - - func shouldTrhottle() -> Bool { - return !shouldSend() - } - - func perform(action: @escaping () -> Void) { - if shouldSend() { - action() - } - } -} -#endif diff --git a/ios/RNMBX/RNMBXMapView.swift b/ios/RNMBX/RNMBXMapView.swift index 80c77e43f..817dcb38a 100644 --- a/ios/RNMBX/RNMBXMapView.swift +++ b/ios/RNMBX/RNMBXMapView.swift @@ -71,15 +71,10 @@ class FeatureEntry { } } -#if RNMBX_11 extension QueriedRenderedFeature { var feature : Feature { return queriedFeature.feature } } -#else -typealias QueriedRenderedFeature = QueriedFeature -#endif -#if RNMBX_11 public struct MapEventType { var method: (_ map: MapboxMap) -> Signal @@ -118,7 +113,6 @@ public struct MapEventType { } typealias MapLoadingErrorPayload = MapLoadingError -#endif class RNMBXCameraChanged : RNMBXEvent, RCTEvent { init(type: EventType, payload: [String:Any?]?, reactTag: NSNumber) { @@ -185,10 +179,8 @@ open class RNMBXMapView: UIView, RCTInvalidating { public func invalidate() { self.removeAllFeaturesFromMap(reason: .ViewRemoval) -#if RNMBX_11 cancelables.forEach { $0.cancel() } cancelables.removeAll() -#endif _mapView.gestures.delegate = nil _mapView.removeFromSuperview() @@ -235,9 +227,7 @@ open class RNMBXMapView: UIView, RCTInvalidating { @objc public var mapViewImpl : String? = nil -#if RNMBX_11 var cancelables = Set() -#endif lazy var pointAnnotationManager : RNMBXPointAnnotationManager = { let result = RNMBXPointAnnotationManager(annotations: mapView.annotations, mapView: mapView) @@ -254,16 +244,7 @@ open class RNMBXMapView: UIView, RCTInvalidating { if let mapViewImpl = mapViewImpl, let mapViewInstance = createAndAddMapViewImpl(mapViewImpl, self) { _mapView = mapViewInstance } else { - #if RNMBX_11 _mapView = MapView(frame: self.bounds, mapInitOptions: MapInitOptions()) - #else - let accessToken = RNMBXModule.accessToken - if accessToken == nil { - Logger.log(level: .error, message: "No accessToken set, please call Mapbox.setAccessToken(...)") - } - let resourceOptions = ResourceOptions(accessToken: accessToken ?? "") - _mapView = MapView(frame: frame, mapInitOptions: MapInitOptions(resourceOptions: resourceOptions)) - #endif _mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] addSubview(_mapView) } @@ -597,9 +578,7 @@ open class RNMBXMapView: UIView, RCTInvalidating { var rotateEnabled: Bool? = nil; var panEnabled: Bool? = nil; var panDecelerationFactor: CGFloat? = nil; - #if RNMBX_11 var simultaneousRotateAndPinchZoomEnabled: Bool? = nil; - #endif } var gestureSettings = GestureSettings() @@ -644,11 +623,9 @@ open class RNMBXMapView: UIView, RCTInvalidating { if let panDecelerationFactor = value["panDecelerationFactor"] as? NSNumber { options.panDecelerationFactor = panDecelerationFactor.CGFloat } -#if RNMBX_11 if let simultaneousRotateAndPinchZoomEnabled = value["simultaneousRotateAndPinchZoomEnabled"] as? NSNumber { options.simultaneousRotateAndPinchZoomEnabled = simultaneousRotateAndPinchZoomEnabled.boolValue } -#endif /* android only if let zoomAnimationAmount = value["zoomAnimationAmount"] as? NSNumber { options.zoomAnimationAmount = zoomAnimationAmount.CGFloat @@ -694,11 +671,9 @@ open class RNMBXMapView: UIView, RCTInvalidating { if let panDecelerationFactor = settings.panDecelerationFactor as? CGFloat { options.panDecelerationFactor = panDecelerationFactor } -#if RNMBX_11 if let simultaneousRotateAndPinchZoomEnabled = settings.simultaneousRotateAndPinchZoomEnabled as? Bool { options.simultaneousRotateAndPinchZoomEnabled = simultaneousRotateAndPinchZoomEnabled } -#endif /* android only if let zoomAnimationAmount = value["zoomAnimationAmount"] as? NSNumber { options.zoomAnimationAmount = zoomAnimationAmount.CGFloat @@ -1048,7 +1023,6 @@ open class RNMBXMapView: UIView, RCTInvalidating { // MARK: - event handlers extension RNMBXMapView { - #if RNMBX_11 private func onEvery(event: MapEventType, handler: @escaping (RNMBXMapView, T) -> Void) { let signal = event.method(self.mapView.mapboxMap) signal.observe { [weak self] (mapEvent) in @@ -1066,27 +1040,6 @@ extension RNMBXMapView { handler(self, mapEvent) }.store(in: &cancelables) } - #else - private func onEvery(event: MapEvents.Event, handler: @escaping (RNMBXMapView, MapEvent) -> Void) { - let eventListener = self.mapView.mapboxMap.onEvery(event: event) { [weak self](mapEvent) in - guard let self = self else { return } - - handler(self, mapEvent) - } - eventListeners.append(eventListener) - if eventListeners.count > 20 { - Logger.log(level:.warn, message: "RNMBXMapView.onEvery, too much handler installed"); - } - } - - private func onNext(event: MapEvents.Event, handler: @escaping (RNMBXMapView, MapEvent) -> Void) { - self.mapView.mapboxMap.onNext(event: event) { [weak self](mapEvent) in - guard let self = self else { return } - - handler(self, mapEvent) - } - } - #endif @objc public func setReactOnMapChange(_ value: @escaping RCTBubblingEventBlock) { self.reactOnMapChange = value @@ -1183,11 +1136,7 @@ extension RNMBXMapView { public func setupEvents() { self.onEvery(event: .mapLoadingError, handler: { (self, event) in let eventPayload : MapLoadingErrorPayload = event.payload - #if RNMBX_11 let error = eventPayload - #else - let error = eventPayload.error - #endif var payload : [String:String] = [ "error": error.errorDescription ?? error.localizedDescription ] @@ -1339,11 +1288,7 @@ extension RNMBXMapView { extension MapboxMaps.PointAnnotationManager { public func refresh() { - #if !RNMBX_11 - syncSourceAndLayerIfNeeded() - #else self.annotations = annotations - #endif } } @@ -1587,7 +1532,6 @@ extension RNMBXMapView { typealias LayerSourceDetails = (source: String?, sourceLayer: String?) -#if RNMBX_11 func getLayerSourceDetails(layer: (any Layer)?) -> LayerSourceDetails? { if let circleLayer = layer as? CircleLayer { return (circleLayer.source, circleLayer.sourceLayer) @@ -1609,7 +1553,6 @@ func getLayerSourceDetails(layer: (any Layer)?) -> LayerSourceDetails? { return nil } } -#endif extension RNMBXMapView { func setSourceVisibility(_ visible: Bool, sourceId: String, sourceLayerId: String?) -> Void { @@ -1620,11 +1563,7 @@ extension RNMBXMapView { try style.layer(withId: layerInfo.id) } - #if RNMBX_11 - let sourceDetails = getLayerSourceDetails(layer: layer) - #else - let sourceDetails: LayerSourceDetails? = (source: layer?.source, sourceLayer: layer?.sourceLayer) - #endif + let sourceDetails = getLayerSourceDetails(layer: layer) if let layer = layer, let sourceDetails = sourceDetails { if sourceDetails.source == sourceId { @@ -1690,12 +1629,10 @@ class RNMBXPointAnnotationManager : AnnotationInteractionDelegate { return rnmbxPointAnnotation } } - #if RNMBX_11 // see https://github.com/rnmapbox/maps/issues/3121 if let rnmbxPointAnnotation = annotations.object(forKey: annotation.id as NSString) { return rnmbxPointAnnotation; } - #endif return nil } @@ -1879,19 +1816,15 @@ class RNMBXPointAnnotationManager : AnnotationInteractionDelegate { manager.annotations.removeAll(where: {$0.id == annotation.id}) } - #if RNMBX_11 var annotations = NSMapTable.init( keyOptions: .copyIn, valueOptions: .weakMemory ) - #endif func add(_ annotation: PointAnnotation, _ rnmbxPointAnnotation: RNMBXPointAnnotation) { manager.annotations.append(annotation) manager.refresh() - #if RNMBX_11 annotations.setObject(rnmbxPointAnnotation, forKey: annotation.id as NSString) - #endif } func update(_ annotation: PointAnnotation) { diff --git a/ios/RNMBX/RNMBXMapViewManager.swift b/ios/RNMBX/RNMBXMapViewManager.swift index 1b650bf37..f5a46de9a 100644 --- a/ios/RNMBX/RNMBXMapViewManager.swift +++ b/ios/RNMBX/RNMBXMapViewManager.swift @@ -1,10 +1,8 @@ import MapboxMaps -#if RNMBX_11 - extension QueriedSourceFeature { - var feature: Feature { return self.queriedFeature.feature } - } -#endif +extension QueriedSourceFeature { + var feature: Feature { return self.queriedFeature.feature } +} #if !RCT_NEW_ARCH_ENABLED @@ -154,7 +152,6 @@ extension RNMBXMapViewManager { resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) { view.withMapboxMap { map in - #if RNMBX_11 map.setFeatureState( sourceId: sourceId, sourceLayerId: sourceLayerId, @@ -166,15 +163,6 @@ extension RNMBXMapViewManager { case .failure(let error): rejecter("setFeatureState", "failed to set feature state", error) } } - #else - map.setFeatureState( - sourceId: sourceId, - sourceLayerId: sourceLayerId, - featureId: featureId, - state: state - ) - resolver(nil) - #endif } } @@ -210,7 +198,6 @@ extension RNMBXMapViewManager { resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) { view.withMapboxMap { map in - #if RNMBX_11 map.removeFeatureState( sourceId: sourceId, sourceLayerId: sourceLayerId, @@ -222,15 +209,6 @@ extension RNMBXMapViewManager { case .failure(let error): rejecter("removeFeatureState", "failed to remove feature state", error) } } - #else - map.removeFeatureState( - sourceId: sourceId, - sourceLayerId: sourceLayerId, - featureId: featureId, - stateKey: stateKey - ) - resolver(nil) - #endif } } } @@ -350,11 +328,7 @@ extension RNMBXMapViewManager { } static func clearData(_ view: RNMBXMapView, completion: @escaping (Error?) -> Void) { - #if RNMBX_11 - MapboxMap.clearData(completion: completion) - #else - view.mapboxMap.clearData(completion: completion) - #endif + MapboxMap.clearData(completion: completion) } @objc public static func clearData( diff --git a/ios/RNMBX/RNMBXMarkerView.swift b/ios/RNMBX/RNMBXMarkerView.swift index 3998d23e2..29af2085f 100644 --- a/ios/RNMBX/RNMBXMarkerView.swift +++ b/ios/RNMBX/RNMBXMarkerView.swift @@ -227,10 +227,8 @@ public class RNMBXMarkerView: UIView, RNMBXMapComponent { offsetY: offset.dy, selected: isSelected ) - #if RNMBX_11 options.allowOverlapWithPuck = allowOverlapWithPuck options.ignoreCameraPadding = true - #endif return options } diff --git a/ios/RNMBX/RNMBXModelLayer.swift b/ios/RNMBX/RNMBXModelLayer.swift index 8a4fc6259..425e97912 100644 --- a/ios/RNMBX/RNMBXModelLayer.swift +++ b/ios/RNMBX/RNMBXModelLayer.swift @@ -6,11 +6,7 @@ public class RNMBXModelLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let vectorSource : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source: sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.sourceLayer = self.sourceLayerID layer.source = sourceID return layer @@ -24,7 +20,6 @@ public class RNMBXModelLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout ModelLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -47,7 +42,6 @@ public class RNMBXModelLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXModels.swift b/ios/RNMBX/RNMBXModels.swift index bae2426b5..96402cff2 100644 --- a/ios/RNMBX/RNMBXModels.swift +++ b/ios/RNMBX/RNMBXModels.swift @@ -49,9 +49,7 @@ open class RNMBXModels : UIView, RNMBXMapComponent { public func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool { modelIdToUrl.forEach { (id, _) in - #if RNMBX_11 try? map._mapView?.mapboxMap.removeStyleModel(modelId: id) - #endif } return true } diff --git a/ios/RNMBX/RNMBXModule.swift b/ios/RNMBX/RNMBXModule.swift index c3b82bcc0..7d37b4ea9 100644 --- a/ios/RNMBX/RNMBXModule.swift +++ b/ios/RNMBX/RNMBXModule.swift @@ -13,15 +13,9 @@ class RNMBXModule : NSObject { public static var accessToken : String? { didSet { -#if RNMBX_11 if let token = accessToken { MapboxOptions.accessToken = token } -#else - if let token = accessToken { - ResourceOptionsManager.default.resourceOptions.accessToken = token - } -#endif } } @@ -133,9 +127,8 @@ class RNMBXModule : NSObject { @objc func clearData(_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) { - + DispatchQueue.main.async { - #if RNMBX_11 MapboxMap.clearData { error in if let error = error { rejecter("error", error.localizedDescription, error) @@ -143,15 +136,6 @@ class RNMBXModule : NSObject { resolver(nil) } } - #else - MapboxMap.clearData(for: ResourceOptions(accessToken: RNMBXModule.accessToken ?? "")) { error in - if let error = error { - rejecter("error", error.localizedDescription, error) - } else { - resolver(nil) - } - } - #endif } } } diff --git a/ios/RNMBX/RNMBXRasterArraySource.swift b/ios/RNMBX/RNMBXRasterArraySource.swift index 46b8e270d..cbd37cdf4 100644 --- a/ios/RNMBX/RNMBXRasterArraySource.swift +++ b/ios/RNMBX/RNMBXRasterArraySource.swift @@ -1,4 +1,3 @@ -#if RNMBX_11 @_spi(Experimental) import MapboxMaps @objc @@ -44,4 +43,3 @@ public class RNMBXRasterArraySource : RNMBXSource { } } -#endif diff --git a/ios/RNMBX/RNMBXRasterArraySourceComponentView.mm b/ios/RNMBX/RNMBXRasterArraySourceComponentView.mm index e2bb72f33..d2fbd0101 100644 --- a/ios/RNMBX/RNMBXRasterArraySourceComponentView.mm +++ b/ios/RNMBX/RNMBXRasterArraySourceComponentView.mm @@ -16,8 +16,6 @@ @interface RNMBXRasterArraySourceComponentView () @end -#if RNMBX_11 - @implementation RNMBXRasterArraySourceComponentView { RNMBXRasterArraySource *_view; } @@ -117,41 +115,6 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & @end -#else // !RNMBX_11 - -// RasterArraySource is only available in Mapbox v11+ -// Provide a stub implementation for v10 builds - -@implementation RNMBXRasterArraySourceComponentView - -+ (void)load -{ - [super load]; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); - _props = defaultProps; - } - return self; -} - -+ (ComponentDescriptorProvider)componentDescriptorProvider -{ - return concreteComponentDescriptorProvider(); -} - -- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps -{ - [super updateProps:props oldProps:oldProps]; -} - -@end - -#endif // RNMBX_11 - Class RNMBXRasterArraySourceCls(void) { return RNMBXRasterArraySourceComponentView.class; diff --git a/ios/RNMBX/RNMBXRasterArraySourceViewManager.swift b/ios/RNMBX/RNMBXRasterArraySourceViewManager.swift index dffede800..d5b3e13d0 100644 --- a/ios/RNMBX/RNMBXRasterArraySourceViewManager.swift +++ b/ios/RNMBX/RNMBXRasterArraySourceViewManager.swift @@ -1,7 +1,6 @@ import Foundation import MapboxMaps -#if RNMBX_11 @objc(RNMBXRasterArraySourceViewManager) class RNMBXRasterArraySourceViewManager : RCTViewManager { @objc @@ -13,4 +12,3 @@ class RNMBXRasterArraySourceViewManager : RCTViewManager { return RNMBXRasterArraySource() } } -#endif diff --git a/ios/RNMBX/RNMBXRasterDemSource.swift b/ios/RNMBX/RNMBXRasterDemSource.swift index 5be11352d..07a8fad72 100644 --- a/ios/RNMBX/RNMBXRasterDemSource.swift +++ b/ios/RNMBX/RNMBXRasterDemSource.swift @@ -30,11 +30,7 @@ public class RNMBXRasterDemSource : RNMBXSource { override func makeSource() -> Source { - #if RNMBX_11 var result = SourceType(id: self.id) - #else - var result = SourceType() - #endif if let url = url { result.url = url } else if let tileUrlTemplates = tileUrlTemplates { diff --git a/ios/RNMBX/RNMBXRasterLayer.swift b/ios/RNMBX/RNMBXRasterLayer.swift index fec3d6657..97942e283 100644 --- a/ios/RNMBX/RNMBXRasterLayer.swift +++ b/ios/RNMBX/RNMBXRasterLayer.swift @@ -6,11 +6,7 @@ public class RNMBXRasterLayer: RNMBXLayer { override func makeLayer(style: Style) throws -> Layer { // let source : ImageSource = try self.sourceWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source: sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.source = sourceID return layer } @@ -19,7 +15,6 @@ public class RNMBXRasterLayer: RNMBXLayer { func setCommonOptions(_ layer: inout RasterLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -42,7 +37,6 @@ public class RNMBXRasterLayer: RNMBXLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXRasterParticleLayer.swift b/ios/RNMBX/RNMBXRasterParticleLayer.swift index aaff23bdd..53caf1cd0 100644 --- a/ios/RNMBX/RNMBXRasterParticleLayer.swift +++ b/ios/RNMBX/RNMBXRasterParticleLayer.swift @@ -1,4 +1,3 @@ -#if RNMBX_11 @_spi(Experimental) import MapboxMaps @objc(RNMBXRasterParticleLayer) @@ -15,7 +14,6 @@ public class RNMBXRasterParticleLayer: RNMBXLayer { func setCommonOptions(_ layer: inout RasterParticleLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -38,7 +36,6 @@ public class RNMBXRasterParticleLayer: RNMBXLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } @@ -97,4 +94,3 @@ public class RNMBXRasterParticleLayer: RNMBXLayer { return LayerType.self } } -#endif diff --git a/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm b/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm index 47def4db4..537e7d034 100644 --- a/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm +++ b/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm @@ -17,8 +17,6 @@ @interface RNMBXRasterParticleLayerComponentView () @end -#if RNMBX_11 - @implementation RNMBXRasterParticleLayerComponentView { RNMBXRasterParticleLayer *_view; } @@ -70,38 +68,6 @@ - (void)prepareForRecycle @end -#else // !RNMBX_11 - -@implementation RNMBXRasterParticleLayerComponentView - -+ (void)load -{ - [super load]; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); - _props = defaultProps; - } - return self; -} - -+ (ComponentDescriptorProvider)componentDescriptorProvider -{ - return concreteComponentDescriptorProvider(); -} - -- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps -{ - [super updateProps:props oldProps:oldProps]; -} - -@end - -#endif // RNMBX_11 - Class RNMBXRasterParticleLayerCls(void) { return RNMBXRasterParticleLayerComponentView.class; diff --git a/ios/RNMBX/RNMBXRasterParticleLayerViewManager.swift b/ios/RNMBX/RNMBXRasterParticleLayerViewManager.swift index d9129f1b7..e2023d4f7 100644 --- a/ios/RNMBX/RNMBXRasterParticleLayerViewManager.swift +++ b/ios/RNMBX/RNMBXRasterParticleLayerViewManager.swift @@ -1,6 +1,5 @@ import Foundation -#if RNMBX_11 @objc(RNMBXRasterParticleLayerViewManager) class RNMBXRasterParticleLayerViewManager: RCTViewManager { @objc @@ -14,4 +13,3 @@ class RNMBXRasterParticleLayerViewManager: RCTViewManager { return layer } } -#endif diff --git a/ios/RNMBX/RNMBXRasterSource.swift b/ios/RNMBX/RNMBXRasterSource.swift index 9580cc8ab..b88395241 100644 --- a/ios/RNMBX/RNMBXRasterSource.swift +++ b/ios/RNMBX/RNMBXRasterSource.swift @@ -20,11 +20,7 @@ public class RNMBXRasterSource : RNMBXSource { override func makeSource() -> Source { - #if RNMBX_11 var result = RasterSource(id: self.id) - #else - var result = RasterSource() - #endif if let url = url { result.url = url } else { diff --git a/ios/RNMBX/RNMBXShapeSource.swift b/ios/RNMBX/RNMBXShapeSource.swift index c6e993d4c..0a33d4c26 100644 --- a/ios/RNMBX/RNMBXShapeSource.swift +++ b/ios/RNMBX/RNMBXShapeSource.swift @@ -95,11 +95,7 @@ public class RNMBXShapeSource : RNMBXSource { override func makeSource() -> Source { - #if RNMBX_11 var result = GeoJSONSource(id: id) - #else - var result = GeoJSONSource() - #endif if let shapeObject = shapeObject { result.data = toGeoJSONSourceData(shapeObject) @@ -255,14 +251,8 @@ extension RNMBXShapeSource return .featureCollection(featureCollection) case .geometry(let geometry): return .geometry(geometry) - #if RNMBX_11 case .string(_): - // RNMBX_11_TODO throw RNMBXError.parseError("url as shape is not supported when updating a ShapeSource") - #else - case .url(_): - throw RNMBXError.parseError("url as shape is not supported when updating a ShapeSource") - #endif } } @@ -293,56 +283,6 @@ extension RNMBXShapeSource } } -#if !RNMBX_11 -class DummyCancellable : Cancelable { - func cancel() {} -} - -#if false -extension MapboxMap { - @discardableResult - public func getGeoJsonClusterExpansionZoom(forSourceId sourceId: String, - feature: Feature, - completion: @escaping (Result) -> Void) -> Cancelable { - self.queryFeatureExtension(for: sourceId, - feature: feature, - extension: "supercluster", - extensionField: "expansion-zoom", - args: nil, - completion: completion) - return DummyCancellable() - } - @discardableResult - public func getGeoJsonClusterChildren(forSourceId sourceId: String, - feature: Feature, - completion: @escaping (Result) -> Void) -> Cancelable { - self.queryFeatureExtension(for: sourceId, - feature: feature, - extension: "supercluster", - extensionField: "children", - args: nil, - completion: completion) - return DummyCancellable() - } - - @discardableResult - public func getGeoJsonClusterLeaves(forSourceId sourceId: String, - feature: Feature, - limit: UInt64 = 10, - offset: UInt64 = 0, - completion: @escaping (Result) -> Void) -> Cancelable { - self.queryFeatureExtension(for: sourceId, - feature: /*MapboxCommon.Feature(*/feature/*)*/, - extension: "supercluster", - extensionField: "leaves", - args: ["limit": limit, "offset": offset], - completion: completion) - return DummyCancellable() - } -} -#endif -#endif - // MARK: - getClusterExpansionZoom/getClusterLeaves extension RNMBXShapeSource diff --git a/ios/RNMBX/RNMBXSnapshotModule.swift b/ios/RNMBX/RNMBXSnapshotModule.swift index c6474330c..84c8e583e 100644 --- a/ios/RNMBX/RNMBXSnapshotModule.swift +++ b/ios/RNMBX/RNMBXSnapshotModule.swift @@ -93,20 +93,11 @@ class RNMBXSnapshotModule : NSObject { let height = jsOptions["height"] as? NSNumber else { throw RNMBXError.paramError("width, height: is not a number") } - #if RNMBX_11 let mapSnapshotOptions = MapSnapshotOptions( size: CGSize(width: width.doubleValue, height: height.doubleValue), pixelRatio: 1.0 ) - #else - let resourceOptions = ResourceOptions(accessToken: RNMBXModule.accessToken!) - let mapSnapshotOptions = MapSnapshotOptions( - size: CGSize(width: width.doubleValue, height: height.doubleValue), - pixelRatio: 1.0, - resourceOptions: resourceOptions - ) - #endif - + return mapSnapshotOptions } } diff --git a/ios/RNMBX/RNMBXSource.swift b/ios/RNMBX/RNMBXSource.swift index 2018719e8..d13af2a58 100644 --- a/ios/RNMBX/RNMBXSource.swift +++ b/ios/RNMBX/RNMBXSource.swift @@ -108,11 +108,7 @@ public class RNMBXSource : RNMBXInteractiveElement { self.ownsSource = true self.source = source logged("SyleSource.addToMap", info: {"id: \(optional: self.id)"}) { - #if RNMBX_11 try style.addSource(source) - #else - try style.addSource(source, id: self.id) - #endif } } diff --git a/ios/RNMBX/RNMBXStyle.swift b/ios/RNMBX/RNMBXStyle.swift index be9eaddc3..c29ad6fd3 100644 --- a/ios/RNMBX/RNMBXStyle.swift +++ b/ios/RNMBX/RNMBXStyle.swift @@ -699,7 +699,6 @@ func rasterLayer(layer: inout RasterLayer, reactStyle:Dictionary, o } } -#if RNMBX_11 func rasterParticleLayer(layer: inout RasterParticleLayer, reactStyle:Dictionary, oldReactStyle:Dictionary?, applyUpdater: @escaping ((inout RasterParticleLayer)->Void)->Void, isValid: @escaping () -> Bool) { guard self._hasReactStyle(reactStyle) else { @@ -740,7 +739,6 @@ func rasterParticleLayer(layer: inout RasterParticleLayer, reactStyle:Dictionary } } } -#endif func hillshadeLayer(layer: inout HillshadeLayer, reactStyle:Dictionary, oldReactStyle:Dictionary?, applyUpdater: @escaping ((inout HillshadeLayer)->Void)->Void, isValid: @escaping () -> Bool) { @@ -1128,7 +1126,7 @@ func setFillTranslate(_ layer: inout FillLayer, styleValue: RNMBXStyleValue) layer.fillTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -1141,7 +1139,7 @@ func setFillTranslateAnchor(_ layer: inout FillLayer, styleValue: RNMBXStyleValu { - layer.fillTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.fillTranslateAnchor = styleValue.mglStyleValueEnum(); } @@ -1157,31 +1155,25 @@ func setFillPattern(_ layer: inout FillLayer, styleValue: RNMBXStyleValue) func setFillPatternCrossFade(_ layer: inout FillLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillPatternCrossFade = styleValue.mglStyleValueNumber(); - #endif } func setFillEmissiveStrength(_ layer: inout FillLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setFillEmissiveStrengthTransition(_ layer: inout FillLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillEmissiveStrengthTransition = styleValue.getTransition(); - #endif } @@ -1190,7 +1182,7 @@ func setLineCap(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - layer.lineCap = styleValue.mglStyleValueEnum(); + layer.lineCap = styleValue.mglStyleValueEnum(); } @@ -1199,7 +1191,7 @@ func setLineJoin(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - layer.lineJoin = styleValue.mglStyleValueEnum(); + layer.lineJoin = styleValue.mglStyleValueEnum(); } @@ -1269,7 +1261,7 @@ func setLineTranslate(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) layer.lineTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -1282,7 +1274,7 @@ func setLineTranslateAnchor(_ layer: inout LineLayer, styleValue: RNMBXStyleValu { - layer.lineTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.lineTranslateAnchor = styleValue.mglStyleValueEnum(); } @@ -1348,7 +1340,7 @@ func setLineDasharray(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) layer.lineDasharray = styleValue.mglStyleValueArrayNumber(); - + } @@ -1375,117 +1367,95 @@ func setLineTrimOffset(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) layer.lineTrimOffset = styleValue.mglStyleValueArrayNumber(); - + } func setLineZOffset(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineZOffset = styleValue.mglStyleValueNumber(); - #endif } func setLineElevationReference(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.lineElevationReference = styleValue.mglStyleValueEnum(); + layer.lineElevationReference = styleValue.mglStyleValueEnum(); - #endif } func setLineCrossSlope(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineCrossSlope = styleValue.mglStyleValueNumber(); - #endif } func setLinePatternCrossFade(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.linePatternCrossFade = styleValue.mglStyleValueNumber(); - #endif } func setLineTrimFadeRange(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineTrimFadeRange = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setLineTrimColor(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineTrimColor = styleValue.mglStyleValueColor(); - #endif } func setLineTrimColorTransition(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineTrimColorTransition = styleValue.getTransition(); - #endif } func setLineEmissiveStrength(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setLineEmissiveStrengthTransition(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setLineOcclusionOpacity(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineOcclusionOpacity = styleValue.mglStyleValueNumber(); - #endif } func setLineOcclusionOpacityTransition(_ layer: inout LineLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.lineOcclusionOpacityTransition = styleValue.getTransition(); - #endif } @@ -1494,7 +1464,7 @@ func setSymbolPlacement(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.symbolPlacement = styleValue.mglStyleValueEnum(); + layer.symbolPlacement = styleValue.mglStyleValueEnum(); } @@ -1530,7 +1500,7 @@ func setSymbolZOrder(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.symbolZOrder = styleValue.mglStyleValueEnum(); + layer.symbolZOrder = styleValue.mglStyleValueEnum(); } @@ -1566,7 +1536,7 @@ func setIconRotationAlignment(_ layer: inout SymbolLayer, styleValue: RNMBXStyle { - layer.iconRotationAlignment = styleValue.mglStyleValueEnum(); + layer.iconRotationAlignment = styleValue.mglStyleValueEnum(); } @@ -1584,7 +1554,7 @@ func setIconTextFit(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.iconTextFit = styleValue.mglStyleValueEnum(); + layer.iconTextFit = styleValue.mglStyleValueEnum(); } @@ -1594,7 +1564,7 @@ func setIconTextFitPadding(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVal layer.iconTextFitPadding = styleValue.mglStyleValueArrayNumber(); - + } @@ -1639,7 +1609,7 @@ func setIconOffset(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.iconOffset = styleValue.mglStyleValueArrayNumber(); - + } @@ -1647,7 +1617,7 @@ func setIconAnchor(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.iconAnchor = styleValue.mglStyleValueEnum(); + layer.iconAnchor = styleValue.mglStyleValueEnum(); } @@ -1656,7 +1626,7 @@ func setIconPitchAlignment(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVal { - layer.iconPitchAlignment = styleValue.mglStyleValueEnum(); + layer.iconPitchAlignment = styleValue.mglStyleValueEnum(); } @@ -1665,7 +1635,7 @@ func setTextPitchAlignment(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVal { - layer.textPitchAlignment = styleValue.mglStyleValueEnum(); + layer.textPitchAlignment = styleValue.mglStyleValueEnum(); } @@ -1674,7 +1644,7 @@ func setTextRotationAlignment(_ layer: inout SymbolLayer, styleValue: RNMBXStyle { - layer.textRotationAlignment = styleValue.mglStyleValueEnum(); + layer.textRotationAlignment = styleValue.mglStyleValueEnum(); } @@ -1693,7 +1663,7 @@ func setTextFont(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.textFont = styleValue.mglStyleValueArrayString(); - + } @@ -1737,7 +1707,7 @@ func setTextJustify(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.textJustify = styleValue.mglStyleValueEnum(); + layer.textJustify = styleValue.mglStyleValueEnum(); } @@ -1756,7 +1726,7 @@ func setTextVariableAnchor(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVal layer.textVariableAnchor = styleValue.mglStyleValueArrayTextVariableAnchor(); - + } @@ -1764,7 +1734,7 @@ func setTextAnchor(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.textAnchor = styleValue.mglStyleValueEnum(); + layer.textAnchor = styleValue.mglStyleValueEnum(); } @@ -1783,7 +1753,7 @@ func setTextWritingMode(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.textWritingMode = styleValue.mglStyleValueArrayTextWritingMode(); - + } @@ -1818,7 +1788,7 @@ func setTextTransform(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - layer.textTransform = styleValue.mglStyleValueEnum(); + layer.textTransform = styleValue.mglStyleValueEnum(); } @@ -1828,7 +1798,7 @@ func setTextOffset(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.textOffset = styleValue.mglStyleValueArrayNumber(); - + } @@ -1939,7 +1909,7 @@ func setIconTranslate(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.iconTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -1952,7 +1922,7 @@ func setIconTranslateAnchor(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVa { - layer.iconTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.iconTranslateAnchor = styleValue.mglStyleValueEnum(); } @@ -2032,7 +2002,7 @@ func setTextTranslate(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) layer.textTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -2045,143 +2015,115 @@ func setTextTranslateAnchor(_ layer: inout SymbolLayer, styleValue: RNMBXStyleVa { - layer.textTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.textTranslateAnchor = styleValue.mglStyleValueEnum(); } func setSymbolZElevate(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.symbolZElevate = styleValue.mglStyleValueBoolean(); - #endif } func setSymbolElevationReference(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.symbolElevationReference = styleValue.mglStyleValueEnum(); + layer.symbolElevationReference = styleValue.mglStyleValueEnum(); - #endif } func setIconOcclusionOpacity(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconOcclusionOpacity = styleValue.mglStyleValueNumber(); - #endif } func setIconOcclusionOpacityTransition(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconOcclusionOpacityTransition = styleValue.getTransition(); - #endif } func setIconEmissiveStrength(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setIconEmissiveStrengthTransition(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setTextEmissiveStrength(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.textEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setTextEmissiveStrengthTransition(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.textEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setIconImageCrossFade(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconImageCrossFade = styleValue.mglStyleValueNumber(); - #endif } func setTextOcclusionOpacity(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.textOcclusionOpacity = styleValue.mglStyleValueNumber(); - #endif } func setTextOcclusionOpacityTransition(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.textOcclusionOpacityTransition = styleValue.getTransition(); - #endif } func setIconColorSaturation(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.iconColorSaturation = styleValue.mglStyleValueNumber(); - #endif } func setSymbolZOffset(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.symbolZOffset = styleValue.mglStyleValueNumber(); - #endif } func setSymbolZOffsetTransition(_ layer: inout SymbolLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.symbolZOffsetTransition = styleValue.getTransition(); - #endif } @@ -2261,7 +2203,7 @@ func setCircleTranslate(_ layer: inout CircleLayer, styleValue: RNMBXStyleValue) layer.circleTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -2274,7 +2216,7 @@ func setCircleTranslateAnchor(_ layer: inout CircleLayer, styleValue: RNMBXStyle { - layer.circleTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.circleTranslateAnchor = styleValue.mglStyleValueEnum(); } @@ -2283,7 +2225,7 @@ func setCirclePitchScale(_ layer: inout CircleLayer, styleValue: RNMBXStyleValue { - layer.circlePitchScale = styleValue.mglStyleValueEnum(); + layer.circlePitchScale = styleValue.mglStyleValueEnum(); } @@ -2292,7 +2234,7 @@ func setCirclePitchAlignment(_ layer: inout CircleLayer, styleValue: RNMBXStyleV { - layer.circlePitchAlignment = styleValue.mglStyleValueEnum(); + layer.circlePitchAlignment = styleValue.mglStyleValueEnum(); } @@ -2341,31 +2283,25 @@ func setCircleStrokeOpacityTransition(_ layer: inout CircleLayer, styleValue: RN func setCircleElevationReference(_ layer: inout CircleLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.circleElevationReference = styleValue.mglStyleValueEnum(); + layer.circleElevationReference = styleValue.mglStyleValueEnum(); - #endif } func setCircleEmissiveStrength(_ layer: inout CircleLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.circleEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setCircleEmissiveStrengthTransition(_ layer: inout CircleLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.circleEmissiveStrengthTransition = styleValue.getTransition(); - #endif } @@ -2444,13 +2380,11 @@ func setFillExtrusionStyleLayerVisibility(_ layer: inout FillExtrusionLayer, sty func setFillExtrusionEdgeRadius(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionEdgeRadius = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionOpacity(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) @@ -2486,7 +2420,7 @@ func setFillExtrusionTranslate(_ layer: inout FillExtrusionLayer, styleValue: RN layer.fillExtrusionTranslate = styleValue.mglStyleValueArrayNumber(); - + } @@ -2499,7 +2433,7 @@ func setFillExtrusionTranslateAnchor(_ layer: inout FillExtrusionLayer, styleVal { - layer.fillExtrusionTranslateAnchor = styleValue.mglStyleValueEnum(); + layer.fillExtrusionTranslateAnchor = styleValue.mglStyleValueEnum(); } @@ -2580,255 +2514,201 @@ func setFillExtrusionAmbientOcclusionRadiusTransition(_ layer: inout FillExtrusi func setFillExtrusionRoundedRoof(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionRoundedRoof = styleValue.mglStyleValueBoolean(); - #endif } func setFillExtrusionPatternCrossFade(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionPatternCrossFade = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionHeightAlignment(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.fillExtrusionHeightAlignment = styleValue.mglStyleValueEnum(); + layer.fillExtrusionHeightAlignment = styleValue.mglStyleValueEnum(); - #endif } func setFillExtrusionBaseAlignment(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.fillExtrusionBaseAlignment = styleValue.mglStyleValueEnum(); + layer.fillExtrusionBaseAlignment = styleValue.mglStyleValueEnum(); - #endif } func setFillExtrusionAmbientOcclusionWallRadius(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionWallRadius = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionAmbientOcclusionWallRadiusTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionWallRadiusTransition = styleValue.getTransition(); - #endif } func setFillExtrusionAmbientOcclusionGroundRadius(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionGroundRadius = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionAmbientOcclusionGroundRadiusTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionGroundRadiusTransition = styleValue.getTransition(); - #endif } func setFillExtrusionAmbientOcclusionGroundAttenuation(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionGroundAttenuation = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionAmbientOcclusionGroundAttenuationTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionAmbientOcclusionGroundAttenuationTransition = styleValue.getTransition(); - #endif } func setFillExtrusionFloodLightColor(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightColor = styleValue.mglStyleValueColor(); - #endif } func setFillExtrusionFloodLightColorTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightColorTransition = styleValue.getTransition(); - #endif } func setFillExtrusionFloodLightIntensity(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightIntensity = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionFloodLightIntensityTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightIntensityTransition = styleValue.getTransition(); - #endif } func setFillExtrusionFloodLightWallRadius(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightWallRadius = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionFloodLightWallRadiusTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightWallRadiusTransition = styleValue.getTransition(); - #endif } func setFillExtrusionFloodLightGroundRadius(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightGroundRadius = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionFloodLightGroundRadiusTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightGroundRadiusTransition = styleValue.getTransition(); - #endif } func setFillExtrusionFloodLightGroundAttenuation(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightGroundAttenuation = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionFloodLightGroundAttenuationTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionFloodLightGroundAttenuationTransition = styleValue.getTransition(); - #endif } func setFillExtrusionVerticalScale(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionVerticalScale = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionVerticalScaleTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionVerticalScaleTransition = styleValue.getTransition(); - #endif } func setFillExtrusionCutoffFadeRange(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionCutoffFadeRange = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionEmissiveStrength(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionEmissiveStrengthTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setFillExtrusionLineWidth(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionLineWidth = styleValue.mglStyleValueNumber(); - #endif } func setFillExtrusionLineWidthTransition(_ layer: inout FillExtrusionLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.fillExtrusionLineWidthTransition = styleValue.getTransition(); - #endif } @@ -2926,7 +2806,7 @@ func setRasterResampling(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue { - layer.rasterResampling = styleValue.mglStyleValueEnum(); + layer.rasterResampling = styleValue.mglStyleValueEnum(); } @@ -2942,100 +2822,79 @@ func setRasterFadeDuration(_ layer: inout RasterLayer, styleValue: RNMBXStyleVal func setRasterColor(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterColor = styleValue.mglStyleValueColor(); - #endif } func setRasterColorMix(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterColorMix = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setRasterColorMixTransition(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterColorMixTransition = styleValue.getTransition(); - #endif } func setRasterColorRange(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterColorRange = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setRasterColorRangeTransition(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterColorRangeTransition = styleValue.getTransition(); - #endif } func setRasterEmissiveStrength(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setRasterEmissiveStrengthTransition(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setRasterArrayBand(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterArrayBand = styleValue.mglStyleValueString(); - #endif } func setRasterElevation(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterElevation = styleValue.mglStyleValueNumber(); - #endif } func setRasterElevationTransition(_ layer: inout RasterLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.rasterElevationTransition = styleValue.getTransition(); - #endif } -#if RNMBX_11 func setRasterParticleStyleLayerVisibility(_ layer: inout RasterParticleLayer, styleValue: RNMBXStyleValue) { @@ -3115,7 +2974,6 @@ func setRasterParticleResetRateFactor(_ layer: inout RasterParticleLayer, styleV } -#endif func setHillshadeStyleLayerVisibility(_ layer: inout HillshadeLayer, styleValue: RNMBXStyleValue) @@ -3136,7 +2994,7 @@ func setHillshadeIlluminationAnchor(_ layer: inout HillshadeLayer, styleValue: R { - layer.hillshadeIlluminationAnchor = styleValue.mglStyleValueEnum(); + layer.hillshadeIlluminationAnchor = styleValue.mglStyleValueEnum(); } @@ -3201,9 +3059,7 @@ func setHillshadeAccentColorTransition(_ layer: inout HillshadeLayer, styleValue func setModelStyleLayerVisibility(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.visibility = styleValue.isVisible(); - #endif } func setModelId(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) @@ -3217,20 +3073,16 @@ func setModelId(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) func setModelOpacity(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelOpacity = styleValue.mglStyleValueNumber(); - #endif } func setModelOpacityTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelOpacityTransition = styleValue.getTransition(); - #endif } func setModelRotation(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) @@ -3238,7 +3090,7 @@ func setModelRotation(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) layer.modelRotation = styleValue.mglStyleValueArrayNumber(); - + } @@ -3252,7 +3104,7 @@ func setModelScale(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) layer.modelScale = styleValue.mglStyleValueArrayNumber(); - + } @@ -3263,172 +3115,136 @@ func setModelScaleTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleVa func setModelTranslation(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelTranslation = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setModelTranslationTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelTranslationTransition = styleValue.getTransition(); - #endif } func setModelColor(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelColor = styleValue.mglStyleValueColor(); - #endif } func setModelColorTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelColorTransition = styleValue.getTransition(); - #endif } func setModelColorMixIntensity(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelColorMixIntensity = styleValue.mglStyleValueNumber(); - #endif } func setModelColorMixIntensityTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelColorMixIntensityTransition = styleValue.getTransition(); - #endif } func setModelType(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.modelType = styleValue.mglStyleValueEnum(); + layer.modelType = styleValue.mglStyleValueEnum(); - #endif } func setModelCastShadows(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelCastShadows = styleValue.mglStyleValueBoolean(); - #endif } func setModelReceiveShadows(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelReceiveShadows = styleValue.mglStyleValueBoolean(); - #endif } func setModelAmbientOcclusionIntensity(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelAmbientOcclusionIntensity = styleValue.mglStyleValueNumber(); - #endif } func setModelAmbientOcclusionIntensityTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelAmbientOcclusionIntensityTransition = styleValue.getTransition(); - #endif } func setModelEmissiveStrength(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setModelEmissiveStrengthTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelEmissiveStrengthTransition = styleValue.getTransition(); - #endif } func setModelRoughness(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelRoughness = styleValue.mglStyleValueNumber(); - #endif } func setModelRoughnessTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelRoughnessTransition = styleValue.getTransition(); - #endif } func setModelHeightBasedEmissiveStrengthMultiplier(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelHeightBasedEmissiveStrengthMultiplier = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setModelHeightBasedEmissiveStrengthMultiplierTransition(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelHeightBasedEmissiveStrengthMultiplierTransition = styleValue.getTransition(); - #endif } func setModelCutoffFadeRange(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.modelCutoffFadeRange = styleValue.mglStyleValueNumber(); - #endif } @@ -3477,31 +3293,25 @@ func setBackgroundOpacityTransition(_ layer: inout BackgroundLayer, styleValue: func setBackgroundPitchAlignment(_ layer: inout BackgroundLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 - layer.backgroundPitchAlignment = styleValue.mglStyleValueEnum(); + layer.backgroundPitchAlignment = styleValue.mglStyleValueEnum(); - #endif } func setBackgroundEmissiveStrength(_ layer: inout BackgroundLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.backgroundEmissiveStrength = styleValue.mglStyleValueNumber(); - #endif } func setBackgroundEmissiveStrengthTransition(_ layer: inout BackgroundLayer, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.backgroundEmissiveStrengthTransition = styleValue.getTransition(); - #endif } @@ -3515,7 +3325,7 @@ func setSkyType(_ layer: inout SkyLayer, styleValue: RNMBXStyleValue) { - layer.skyType = styleValue.mglStyleValueEnum(); + layer.skyType = styleValue.mglStyleValueEnum(); } @@ -3525,7 +3335,7 @@ func setSkyAtmosphereSun(_ layer: inout SkyLayer, styleValue: RNMBXStyleValue) layer.skyAtmosphereSun = styleValue.mglStyleValueArrayNumber(); - + } @@ -3543,7 +3353,7 @@ func setSkyGradientCenter(_ layer: inout SkyLayer, styleValue: RNMBXStyleValue) layer.skyGradientCenter = styleValue.mglStyleValueArrayNumber(); - + } @@ -3603,7 +3413,7 @@ func setAnchor(_ layer: inout Light, styleValue: RNMBXStyleValue) { - layer.anchor = styleValue.mglStyleValueAnchorRaw(); + layer.anchor = styleValue.mglStyleValueAnchorRaw(); } @@ -3653,7 +3463,7 @@ func setRange(_ layer: inout Atmosphere, styleValue: RNMBXStyleValue) layer.range = styleValue.mglStyleValueArrayNumber(); - + } @@ -3734,20 +3544,16 @@ func setStarIntensityTransition(_ layer: inout Atmosphere, styleValue: RNMBXStyl func setVerticalRange(_ layer: inout Atmosphere, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.verticalRange = styleValue.mglStyleValueArrayNumber(); - + - #endif } func setVerticalRangeTransition(_ layer: inout Atmosphere, styleValue: RNMBXStyleValue) { - #if RNMBX_11 layer.verticalRangeTransition = styleValue.getTransition(); - #endif } diff --git a/ios/RNMBX/RNMBXStyleImport.swift b/ios/RNMBX/RNMBXStyleImport.swift index 43ea62736..964b1af09 100644 --- a/ios/RNMBX/RNMBXStyleImport.swift +++ b/ios/RNMBX/RNMBXStyleImport.swift @@ -36,13 +36,9 @@ open class RNMBXStyleImport: UIView, RNMBXMapComponent { func apply(mapView: MapView) { if let config = config, let id = id { - #if RNMBX_11 - logged("RNMBXStyleImport.setStyleImportConfigProperties id=\(id)") { - try mapView.mapboxMap.setStyleImportConfigProperties(for: id, configs: config) - } - #else - Logger.error("RNMBXStyleImport.setStyleImportConfigProperties is only implemented on v11") - #endif + logged("RNMBXStyleImport.setStyleImportConfigProperties id=\(id)") { + try mapView.mapboxMap.setStyleImportConfigProperties(for: id, configs: config) + } } } diff --git a/ios/RNMBX/RNMBXStyleValue.swift b/ios/RNMBX/RNMBXStyleValue.swift index 4c0b688a8..b5400933c 100644 --- a/ios/RNMBX/RNMBXStyleValue.swift +++ b/ios/RNMBX/RNMBXStyleValue.swift @@ -203,7 +203,6 @@ class RNMBXStyleValue { } } - #if RNMBX_11 func mglStyleValueNumberRaw() -> Value { guard let value = value as? Dictionary else { Logger.log(level: .error, message: "Invalid value for number: \(value) retuning 0.0") @@ -224,28 +223,6 @@ class RNMBXStyleValue { } return .constant(1.0) } - #else - func mglStyleValueNumberRaw() -> Double { - guard let value = value as? Dictionary else { - Logger.log(level: .error, message: "Invalid value for number: \(value) retuning 0.0") - return 0.0 - } - - let valueObj = RNMBXStyleValue.convert(value["stylevalue"] as! [String:Any]) - - if let num = valueObj as? NSNumber { - return num.doubleValue - } else if let num = valueObj as? Double { - return num - } else if let num = valueObj as? Int { - return Double(num) - } else { - Logger.log(level: .error, message: "Invalid value for number: \(value) retuning 0.0") - return 0.0 - } - return 1.0 - } - #endif func uicolor(_ rgbValue: Int) -> UIColor { return UIColor( @@ -280,7 +257,6 @@ class RNMBXStyleValue { return decodedExpression } - #if RNMBX_11 func mglStyleValueColorRaw() -> Value { guard let value = value as? Dictionary else { Logger.log(level: .error, message: "Invalid value for color: \(value) retuning red") @@ -296,23 +272,6 @@ class RNMBXStyleValue { return .constant(StyleColor(UIColor.red)) } } - #else - func mglStyleValueColorRaw() -> StyleColor { - guard let value = value as? Dictionary else { - Logger.log(level: .error, message: "Invalid value for color: \(value) retuning red") - return StyleColor(UIColor.red) - } - let valueObj = RNMBXStyleValue.convert(value["stylevalue"] as! [String:Any]) - - if let num = valueObj as? Int { - let uicolor = uicolor(num) - return StyleColor(uicolor) - } else { - Logger.log(level: .error, message: "Unexpeted value for color: \(valueObj), retuning red") - return StyleColor(UIColor.red) - } - } - #endif func mglStyleValueBoolean() -> Value { guard let value = value as? Dictionary else { @@ -478,16 +437,10 @@ class RNMBXStyleValue { return Value.constant([]) } - #if RNMBX_11 func mglStyleValueAnchorRaw() -> Value { // RNMBX_11 TODO Support expressions return .constant(mglStyleEnum()) } - #else - func mglStyleValueAnchorRaw() -> Anchor { - return mglStyleEnum() - } - #endif func shouldAddImage() -> Bool { if let uri = getImageURI() { @@ -580,7 +533,6 @@ class RNMBXStyleValue { } } - #if RNMBX_11 func mglStyleValueArrayClipLayerTypes() -> Value<[ClipLayerTypes]> { guard let value = value as? Dictionary else { Logger.log(level: .error, message: "Invalid value for array of ClipLayerTypes: \(value)") @@ -605,9 +557,7 @@ class RNMBXStyleValue { } } } - #endif - #if RNMBX_11 func getSphericalPosition() -> Value<[Double]> { if let array = styleObject as? [NSNumber] { var result = array.map { $0.doubleValue } @@ -617,17 +567,6 @@ class RNMBXStyleValue { Logger.log(level: .error, message: "Expected array of numbers as position received: \(optional: styleObject)") return .constant([]) } - #else - func getSphericalPosition() -> [Double] { - if let array = styleObject as? [NSNumber] { - var result = array.map { $0.doubleValue } - result[0] = deg2rad(result[0]) - return result - } - Logger.log(level: .error, message: "Expected array of numbers as position received: \(optional: styleObject)") - return [] - } - #endif func mglStyleValueFormatted() -> Value { if let value = value as? Dictionary { diff --git a/ios/RNMBX/RNMBXSymbolLayer.swift b/ios/RNMBX/RNMBXSymbolLayer.swift index 9e459daa8..1b9c7a5e4 100644 --- a/ios/RNMBX/RNMBXSymbolLayer.swift +++ b/ios/RNMBX/RNMBXSymbolLayer.swift @@ -7,11 +7,7 @@ public class RNMBXSymbolLayer: RNMBXVectorLayer { override func makeLayer(style: Style) throws -> Layer { let _ : VectorSource = try self.layerWithSourceID(in: style) - #if RNMBX_11 var layer = LayerType(id: self.id!, source: sourceID!) - #else - var layer = LayerType(id: self.id!) - #endif layer.sourceLayer = self.sourceLayerID layer.source = sourceID return layer @@ -25,7 +21,6 @@ public class RNMBXSymbolLayer: RNMBXVectorLayer { func setCommonOptions(_ layer: inout SymbolLayer) -> Bool { var changed = false - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -48,7 +43,6 @@ public class RNMBXSymbolLayer: RNMBXVectorLayer { Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif return changed } diff --git a/ios/RNMBX/RNMBXVectorSource.swift b/ios/RNMBX/RNMBXVectorSource.swift index 80e452bc7..ad07b5bec 100644 --- a/ios/RNMBX/RNMBXVectorSource.swift +++ b/ios/RNMBX/RNMBXVectorSource.swift @@ -15,11 +15,7 @@ public class RNMBXVectorSource : RNMBXTileSource { override func makeSource() -> Source { - #if RNMBX_11 var result = VectorSource(id: self.id) - #else - var result = VectorSource() - #endif if let url = url { result.url = url } else { diff --git a/ios/RNMBX/RNMBXViewport.swift b/ios/RNMBX/RNMBXViewport.swift index af0e75cad..ae47311a1 100644 --- a/ios/RNMBX/RNMBXViewport.swift +++ b/ios/RNMBX/RNMBXViewport.swift @@ -1,10 +1,5 @@ @_spi(Experimental) import MapboxMaps -#if RNMBX_11 -#else -typealias ViewportManager = Viewport -#endif - @objc(RNMBXViewport) open class RNMBXViewport : UIView, RNMBXMapAndMapViewComponent, ViewportStatusObserver { var mapView: MapView? = nil diff --git a/ios/RNMBX/codeparts/LayerPropsCommon.codepart-swift.ejs b/ios/RNMBX/codeparts/LayerPropsCommon.codepart-swift.ejs index 70bfa7cdc..04118ee53 100644 --- a/ios/RNMBX/codeparts/LayerPropsCommon.codepart-swift.ejs +++ b/ios/RNMBX/codeparts/LayerPropsCommon.codepart-swift.ejs @@ -1,7 +1,6 @@ func setCommonOptions(_ layer: inout <%= layerType %>Layer) -> Bool { var changed = false <% if (layerType !== 'Sky') { %> - #if RNMBX_11 if let sourceLayerID = sourceLayerID { layer.sourceLayer = sourceLayerID changed = true @@ -24,7 +23,6 @@ Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)") } } - #endif <% } %> return changed } diff --git a/scripts/templates/RNMBXStyle.swift.ejs b/scripts/templates/RNMBXStyle.swift.ejs index ae721f243..fff61c237 100644 --- a/scripts/templates/RNMBXStyle.swift.ejs +++ b/scripts/templates/RNMBXStyle.swift.ejs @@ -1,9 +1,5 @@ <% const layers = locals.layers; - const v11OnlyLayers = ['raster-particle']; - function isV11OnlyLayer(layer) { - return v11OnlyLayers.includes(layer.name); - } -%> // DO NOT MODIFY // THIS FILE IS AUTOGENERATED @@ -19,9 +15,6 @@ class RNMBXStyle { } <% for (const layer of layers) { %> -<%_ if (isV11OnlyLayer(layer)) { _%> -#if RNMBX_11 -<%_ } _%> func <%- setLayerMethodName(layer, 'ios') -%>(layer: inout <%- getLayerType(layer, 'ios-v10') -%>, reactStyle:Dictionary, oldReactStyle:Dictionary?, applyUpdater: @escaping ((inout <%- getLayerType(layer, 'ios-v10') -%>)->Void)->Void, isValid: @escaping () -> Bool) { guard self._hasReactStyle(reactStyle) else { @@ -66,21 +59,12 @@ func <%- setLayerMethodName(layer, 'ios') -%>(layer: inout <%- getLayerType(laye <% } -%> } } -<%_ if (isV11OnlyLayer(layer)) { _%> -#endif -<%_ } _%> <% } %> <% for (const layer of layers) {%> -<%_ if (isV11OnlyLayer(layer)) { _%> -#if RNMBX_11 -<%_ } _%> <% for (const prop of layer.properties) {%> func set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>(_ layer: inout <%- getLayerType(layer, 'ios-v10') -%>, styleValue: RNMBXStyleValue) { - <%_ if (!isV11OnlyLayer(layer) && !prop.support.basic['v10'].ios) { _%> - #if RNMBX_11 - <%_ } _%> <%_ if (layer.name === 'light' && prop.name === 'position') { _%> layer.position = styleValue.getSphericalPosition(); <%_ } else if (prop.name === 'visibility') { _%> @@ -88,9 +72,9 @@ func set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>(_ layer: inout < <%_ } else { _%> <% if (prop.type === 'enum') { %> <% if (layer.name === 'light') { %> - layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValue<%- pascelCase(prop.name) %>Raw(); + layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValue<%- pascelCase(prop.name) %>Raw(); <% } else { %> - layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValueEnum(); + layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValueEnum(); <% } %> <% } else if (prop.type === 'array') { %> <% if (prop.value === 'enum') { %> @@ -101,7 +85,7 @@ func set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>(_ layer: inout < <%_ } _%> <% } else { %> layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValueArray<%- pascelCase(prop.value) %>(); - <% } %> + <% } %> <% } else { %> <% if (layer.name === 'light') { %> layer.<%- iosV10PropName(prop.name) -%> = styleValue.mglStyleValue<%- pascelCase(prop.type) %>Raw(); @@ -110,27 +94,15 @@ func set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>(_ layer: inout < <% } %> <% } %> <%_ } _%> - <%_ if (!isV11OnlyLayer(layer) && !prop.support.basic['v10'].ios) { _%> - #endif - <%_ } _%> } <%_ if (prop.transition) { _%> func set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>Transition(_ layer: inout <%- getLayerType(layer, 'ios-v10') -%>, styleValue: RNMBXStyleValue) { - <%_ if (!isV11OnlyLayer(layer) && !prop.support.basic['v10'].ios) { _%> - #if RNMBX_11 - <%_ } _%> layer.<%- iosV10PropName(prop.name) -%>Transition = styleValue.getTransition(); - <%_ if (!isV11OnlyLayer(layer) && !prop.support.basic['v10'].ios) { _%> - #endif - <%_ } _%> } <%_ } _%> <% } %> -<%_ if (isV11OnlyLayer(layer)) { _%> -#endif -<%_ } _%> <% } %> func _hasReactStyle(_ reactStyle: Dictionary) -> Bool