diff --git a/Apps/DebugApp/DebugApp/DebugViewController.swift b/Apps/DebugApp/DebugApp/DebugViewController.swift index 03375f3ecef..f307666b17d 100644 --- a/Apps/DebugApp/DebugApp/DebugViewController.swift +++ b/Apps/DebugApp/DebugApp/DebugViewController.swift @@ -25,7 +25,7 @@ public class DebugViewController: UIViewController { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions) mapView.update { (mapOptions) in mapOptions.location.puckType = .puck2D() } diff --git a/Apps/Examples/Examples/All Examples/AnimateGeoJSONLineExample.swift b/Apps/Examples/Examples/All Examples/AnimateGeoJSONLineExample.swift index c75a1ac2215..f950c305fe8 100644 --- a/Apps/Examples/Examples/All Examples/AnimateGeoJSONLineExample.swift +++ b/Apps/Examples/Examples/All Examples/AnimateGeoJSONLineExample.swift @@ -15,14 +15,14 @@ public class AnimateGeoJSONLineExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) let centerCoordinate = CLLocationCoordinate2D(latitude: 45.5076, longitude: -122.6736) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 11.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 11.0)) // Wait for the map to load its style before adding data. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/AnimateLayerExample.swift b/Apps/Examples/Examples/All Examples/AnimateLayerExample.swift index f865b4e7cd1..671208fa2e9 100644 --- a/Apps/Examples/Examples/All Examples/AnimateLayerExample.swift +++ b/Apps/Examples/Examples/All Examples/AnimateLayerExample.swift @@ -15,7 +15,7 @@ public class AnimateLayerExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -23,8 +23,8 @@ public class AnimateLayerExample: UIViewController, ExampleProtocol { let centerCoordinate = CLLocationCoordinate2D(latitude: 37.8, longitude: -96) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 2) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 2)) // Allows the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/BasicMapExample.swift b/Apps/Examples/Examples/All Examples/BasicMapExample.swift index 9f3d53813b4..b3296f1cb23 100644 --- a/Apps/Examples/Examples/All Examples/BasicMapExample.swift +++ b/Apps/Examples/Examples/All Examples/BasicMapExample.swift @@ -10,10 +10,10 @@ public class BasicMapExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] mapView.update { (mapOptions) in - mapOptions.ornaments.showsScale = true + mapOptions.ornaments.scaleBarVisibility = .visible } view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/BuildingExtrusionsExample.swift b/Apps/Examples/Examples/All Examples/BuildingExtrusionsExample.swift index 550e0a09382..6896b2fc702 100644 --- a/Apps/Examples/Examples/All Examples/BuildingExtrusionsExample.swift +++ b/Apps/Examples/Examples/All Examples/BuildingExtrusionsExample.swift @@ -9,7 +9,7 @@ public class BuildingExtrusionsExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/CameraAnimationExample.swift b/Apps/Examples/Examples/All Examples/CameraAnimationExample.swift index 765194ea1d7..13f2340415c 100644 --- a/Apps/Examples/Examples/All Examples/CameraAnimationExample.swift +++ b/Apps/Examples/Examples/All Examples/CameraAnimationExample.swift @@ -15,7 +15,7 @@ public class CameraAnimationExample: UIViewController, ExampleProtocol { } let resourceOptions = ResourceOptions(accessToken: accessToken) - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/CameraAnimatorsExample.swift b/Apps/Examples/Examples/All Examples/CameraAnimatorsExample.swift index bf5110df1f6..e109dc23e43 100644 --- a/Apps/Examples/Examples/All Examples/CameraAnimatorsExample.swift +++ b/Apps/Examples/Examples/All Examples/CameraAnimatorsExample.swift @@ -52,13 +52,13 @@ public class CameraAnimatorsExample: UIViewController, ExampleProtocol { } let resourceOptions = ResourceOptions(accessToken: accessToken) - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) // Center the map over New York City. let newYork = CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060) - mapView.cameraManager.setCamera(centerCoordinate: newYork) + mapView.cameraManager.setCamera(to: CameraOptions(center: newYork)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/ColorExpressionExample.swift b/Apps/Examples/Examples/All Examples/ColorExpressionExample.swift index e3a93e74ae2..b4494466ff7 100644 --- a/Apps/Examples/Examples/All Examples/ColorExpressionExample.swift +++ b/Apps/Examples/Examples/All Examples/ColorExpressionExample.swift @@ -10,7 +10,7 @@ public class ColorExpressionExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -18,8 +18,7 @@ public class ColorExpressionExample: UIViewController, ExampleProtocol { let centerCoordinate = CLLocationCoordinate2D(latitude: 40.58058466412761, longitude: -97.734375) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 3) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, zoom: 3)) // Allows the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in @@ -55,7 +54,8 @@ public class ColorExpressionExample: UIViewController, ExampleProtocol { stops } - if let jsonObject = try? exp.jsonObject() { + if let data = try? JSONEncoder().encode(exp.self), + let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) { try! mapView.__map.setStyleLayerPropertyForLayerId("land", property: "background-color", value: jsonObject) diff --git a/Apps/Examples/Examples/All Examples/Custom2DPuckExample.swift b/Apps/Examples/Examples/All Examples/Custom2DPuckExample.swift index a74a1e353b1..ec25f514e05 100644 --- a/Apps/Examples/Examples/All Examples/Custom2DPuckExample.swift +++ b/Apps/Examples/Examples/All Examples/Custom2DPuckExample.swift @@ -9,7 +9,7 @@ public class Custom2DPuckExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -34,8 +34,8 @@ public class Custom2DPuckExample: UIViewController, ExampleProtocol { } let coordinate = CLLocationCoordinate2D(latitude: 39.085006, longitude: -77.150925) - mapView.cameraManager.setCamera(centerCoordinate: coordinate, - zoom: 14, - pitch: 0) + mapView.cameraManager.setCamera(to: CameraOptions(center: coordinate, + zoom: 14, + pitch: 0)) } } diff --git a/Apps/Examples/Examples/All Examples/Custom3DPuckExample.swift b/Apps/Examples/Examples/All Examples/Custom3DPuckExample.swift index 114c2154199..b77cfa04ff6 100644 --- a/Apps/Examples/Examples/All Examples/Custom3DPuckExample.swift +++ b/Apps/Examples/Examples/All Examples/Custom3DPuckExample.swift @@ -9,7 +9,7 @@ public class Custom3DPuckExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -72,8 +72,8 @@ public class Custom3DPuckExample: UIViewController, ExampleProtocol { } let coordinate = CLLocationCoordinate2D(latitude: 39.085006, longitude: -77.150925) - mapView.cameraManager.setCamera(centerCoordinate: coordinate, - zoom: 14, - pitch: 80) + mapView.cameraManager.setCamera(to: CameraOptions(center: coordinate, + zoom: 14, + pitch: 80)) } } diff --git a/Apps/Examples/Examples/All Examples/CustomLayerExample.swift b/Apps/Examples/Examples/All Examples/CustomLayerExample.swift index eb509bfa5ee..e416a0e90f7 100644 --- a/Apps/Examples/Examples/All Examples/CustomLayerExample.swift +++ b/Apps/Examples/Examples/All Examples/CustomLayerExample.swift @@ -14,7 +14,7 @@ public class CustomLayerExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/CustomPointAnnotationExample.swift b/Apps/Examples/Examples/All Examples/CustomPointAnnotationExample.swift index 88e83c619aa..e5e9aba981d 100644 --- a/Apps/Examples/Examples/All Examples/CustomPointAnnotationExample.swift +++ b/Apps/Examples/Examples/All Examples/CustomPointAnnotationExample.swift @@ -10,15 +10,15 @@ public class CustomPointAnnotationExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) // Center the map camera over New York City let centerCoordinate = CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 9.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 9.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/CustomStyleURLExample.swift b/Apps/Examples/Examples/All Examples/CustomStyleURLExample.swift index 5769cc6c066..02170693c86 100644 --- a/Apps/Examples/Examples/All Examples/CustomStyleURLExample.swift +++ b/Apps/Examples/Examples/All Examples/CustomStyleURLExample.swift @@ -14,7 +14,7 @@ internal class CustomStyleURLExample: UIViewController, ExampleProtocol { fatalError("Style URL is invalid") } - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: .custom(url: customStyleURL)) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: .custom(url: customStyleURL)) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/DataDrivenSymbolsExample.swift b/Apps/Examples/Examples/All Examples/DataDrivenSymbolsExample.swift index 546448cc2a3..978c1437d27 100644 --- a/Apps/Examples/Examples/All Examples/DataDrivenSymbolsExample.swift +++ b/Apps/Examples/Examples/All Examples/DataDrivenSymbolsExample.swift @@ -10,15 +10,15 @@ public class DataDrivenSymbolsExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: .outdoors) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: .outdoors) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) // Set center location let centerCoordinate = CLLocationCoordinate2D(latitude: 37.761, longitude: -119.624) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 10.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 10.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/ExternalVectorSourceExample.swift b/Apps/Examples/Examples/All Examples/ExternalVectorSourceExample.swift index 9cad6202b64..1fa8409edb1 100644 --- a/Apps/Examples/Examples/All Examples/ExternalVectorSourceExample.swift +++ b/Apps/Examples/Examples/All Examples/ExternalVectorSourceExample.swift @@ -8,12 +8,12 @@ public class ExternalVectorSourceExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - mapView.style.styleURI = .light + mapView.style.uri = .light let centerCoordinate = CLLocationCoordinate2D(latitude: 41.878781, longitude: -87.622088) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 12) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 12)) view.addSubview(mapView) // Allow the view controller to receive information about map events. diff --git a/Apps/Examples/Examples/All Examples/FeaturesAtPointExample.swift b/Apps/Examples/Examples/All Examples/FeaturesAtPointExample.swift index 9f456299214..164011e6e30 100644 --- a/Apps/Examples/Examples/All Examples/FeaturesAtPointExample.swift +++ b/Apps/Examples/Examples/All Examples/FeaturesAtPointExample.swift @@ -10,7 +10,7 @@ public class FeaturesAtPointExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -18,8 +18,8 @@ public class FeaturesAtPointExample: UIViewController, ExampleProtocol { let centerCoordinate = CLLocationCoordinate2D(latitude: 39.368279, longitude: -97.646484) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 2.4) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 2.4)) // Allows the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/FitCameraToGeometryExample.swift b/Apps/Examples/Examples/All Examples/FitCameraToGeometryExample.swift index adfee214c6a..b853426bacf 100644 --- a/Apps/Examples/Examples/All Examples/FitCameraToGeometryExample.swift +++ b/Apps/Examples/Examples/All Examples/FitCameraToGeometryExample.swift @@ -16,7 +16,7 @@ public class FitCameraToGeometryExample: UIViewController, ExampleProtocol { } let resourceOptions = ResourceOptions(accessToken: accessToken) - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/FlyToExample.swift b/Apps/Examples/Examples/All Examples/FlyToExample.swift index 06628c944fc..221cb006fa9 100644 --- a/Apps/Examples/Examples/All Examples/FlyToExample.swift +++ b/Apps/Examples/Examples/All Examples/FlyToExample.swift @@ -11,13 +11,13 @@ public class FlyToExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) // Center the map over San Francisco. - mapView.cameraManager.setCamera(centerCoordinate: .sanfrancisco, - zoom: 15) + mapView.cameraManager.setCamera(to: CameraOptions(center: .sanfrancisco, + zoom: 15)) // Allows the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/GeoJSONSourceExample.swift b/Apps/Examples/Examples/All Examples/GeoJSONSourceExample.swift index 650804d65df..7d7256c5a90 100644 --- a/Apps/Examples/Examples/All Examples/GeoJSONSourceExample.swift +++ b/Apps/Examples/Examples/All Examples/GeoJSONSourceExample.swift @@ -10,7 +10,7 @@ public class GeoJSONSourceExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/LayerBelowExample.swift b/Apps/Examples/Examples/All Examples/LayerBelowExample.swift index ec67a341134..ab28f575d26 100644 --- a/Apps/Examples/Examples/All Examples/LayerBelowExample.swift +++ b/Apps/Examples/Examples/All Examples/LayerBelowExample.swift @@ -10,7 +10,7 @@ public class LayerBelowExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) view.addSubview(mapView) // Center the map over downtown Atlanta @@ -18,8 +18,8 @@ public class LayerBelowExample: UIViewController, ExampleProtocol { longitude: -88.137343) // Zoom to cover the whole Atlanta urban area - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 4) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 4)) // Allows the view controller to receive information about map events mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/LayerPositionExample.swift b/Apps/Examples/Examples/All Examples/LayerPositionExample.swift index d851e569723..916cd3a1486 100644 --- a/Apps/Examples/Examples/All Examples/LayerPositionExample.swift +++ b/Apps/Examples/Examples/All Examples/LayerPositionExample.swift @@ -13,7 +13,7 @@ public class LayerPositionExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -21,8 +21,8 @@ public class LayerPositionExample: UIViewController, ExampleProtocol { let centerCoordinate = CLLocationCoordinate2D(latitude: 40.58058466412761, longitude: -97.734375) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 3) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 3)) // Allows the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/LineAnnotationExample.swift b/Apps/Examples/Examples/All Examples/LineAnnotationExample.swift index b576e742457..396388dbd84 100644 --- a/Apps/Examples/Examples/All Examples/LineAnnotationExample.swift +++ b/Apps/Examples/Examples/All Examples/LineAnnotationExample.swift @@ -10,14 +10,14 @@ public class LineAnnotationExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) let centerCoordinate = CLLocationCoordinate2D(latitude: 39.7128, longitude: -75.0060) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 5.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 5.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/LineGradientExample.swift b/Apps/Examples/Examples/All Examples/LineGradientExample.swift index 9d12dbdf93a..988d5bf6bfa 100644 --- a/Apps/Examples/Examples/All Examples/LineGradientExample.swift +++ b/Apps/Examples/Examples/All Examples/LineGradientExample.swift @@ -10,7 +10,7 @@ public class LineGradientExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/MapViewExample.swift b/Apps/Examples/Examples/All Examples/MapViewExample.swift index 893a6f43a36..5826c3a0f37 100644 --- a/Apps/Examples/Examples/All Examples/MapViewExample.swift +++ b/Apps/Examples/Examples/All Examples/MapViewExample.swift @@ -7,7 +7,7 @@ public class MapViewExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - let mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + let mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) NSLayoutConstraint.activate([ @@ -17,7 +17,7 @@ public class MapViewExample: UIViewController, ExampleProtocol { mapView.bottomAnchor.constraint(equalTo: view.bottomAnchor) ]) - mapView.style.styleURI = StyleURI.custom(url: URL(string: "mapbox://styles/examples/cke97f49z5rlg19l310b7uu7j")!) + mapView.style.uri = StyleURI.custom(url: URL(string: "mapbox://styles/examples/cke97f49z5rlg19l310b7uu7j")!) mapView.on(.styleLoaded) { [weak self] _ in // The below line is used for internal testing purposes only. diff --git a/Apps/Examples/Examples/All Examples/OfflineRegionManagerExample.swift b/Apps/Examples/Examples/All Examples/OfflineRegionManagerExample.swift index 3b2b43a22ff..59a94c81693 100644 --- a/Apps/Examples/Examples/All Examples/OfflineRegionManagerExample.swift +++ b/Apps/Examples/Examples/All Examples/OfflineRegionManagerExample.swift @@ -18,7 +18,7 @@ public class OfflineRegionManagerExample: UIViewController, ExampleProtocol { super.viewDidLoad() print("This example uses a deprecated API, and will be removed in a future release.") - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: .light) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -42,7 +42,7 @@ public class OfflineRegionManagerExample: UIViewController, ExampleProtocol { } internal func setupExample() { - let offlineRegionDef = OfflineRegionGeometryDefinition(styleURL: mapView.style.styleURI.url.absoluteString, + let offlineRegionDef = OfflineRegionGeometryDefinition(styleURL: mapView.style.uri.rawValue.absoluteURL.absoluteString, geometry: MBXGeometry(coordinate: coord), minZoom: zoom - 2, maxZoom: zoom + 2, diff --git a/Apps/Examples/Examples/All Examples/PointAnnotationExample.swift b/Apps/Examples/Examples/All Examples/PointAnnotationExample.swift index db49b7803c9..b5d47fcc387 100644 --- a/Apps/Examples/Examples/All Examples/PointAnnotationExample.swift +++ b/Apps/Examples/Examples/All Examples/PointAnnotationExample.swift @@ -10,15 +10,15 @@ public class PointAnnotationExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) // Center the map camera over Copenhagen. let centerCoordinate = CLLocationCoordinate2D(latitude: 55.665957, longitude: 12.550343) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 8.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 8.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/PolygonAnnotationExample.swift b/Apps/Examples/Examples/All Examples/PolygonAnnotationExample.swift index a116c66e09d..3de995f7df2 100644 --- a/Apps/Examples/Examples/All Examples/PolygonAnnotationExample.swift +++ b/Apps/Examples/Examples/All Examples/PolygonAnnotationExample.swift @@ -9,14 +9,14 @@ public class PolygonAnnotationExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) let centerCoordinate = CLLocationCoordinate2D(latitude: 25.04579, longitude: -88.90136) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 5.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 5.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/RestrictCoordinateBoundsExample.swift b/Apps/Examples/Examples/All Examples/RestrictCoordinateBoundsExample.swift index 6dace26621b..c5756dd0742 100644 --- a/Apps/Examples/Examples/All Examples/RestrictCoordinateBoundsExample.swift +++ b/Apps/Examples/Examples/All Examples/RestrictCoordinateBoundsExample.swift @@ -9,7 +9,7 @@ public class RestrictCoordinateBoundsExample: UIViewController, ExampleProtocol override public func viewDidLoad() { super.viewDidLoad() - let mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + let mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) diff --git a/Apps/Examples/Examples/All Examples/SceneKitExample.swift b/Apps/Examples/Examples/All Examples/SceneKitExample.swift index d4ceeba22a8..18d8b8e19c6 100644 --- a/Apps/Examples/Examples/All Examples/SceneKitExample.swift +++ b/Apps/Examples/Examples/All Examples/SceneKitExample.swift @@ -20,15 +20,15 @@ public class SceneKitExample: UIViewController, ExampleProtocol, CustomLayerHost override public func viewDidLoad() { super.viewDidLoad() - self.mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + self.mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.view.addSubview(mapView) - mapView.cameraManager.setCamera( - centerCoordinate: self.modelOrigin, - zoom: 18, - bearing: 180, - pitch: 60 - ) + + let camera = CameraOptions(center: self.modelOrigin, + zoom: 18, + bearing: 180, + pitch: 60) + mapView.cameraManager.setCamera(to: camera) self.mapView.on(.styleLoaded) { [weak self] _ in self?.addModelAndTerrain() diff --git a/Apps/Examples/Examples/All Examples/SelectAnnotationExample.swift b/Apps/Examples/Examples/All Examples/SelectAnnotationExample.swift index d274e538e81..943aa029e82 100644 --- a/Apps/Examples/Examples/All Examples/SelectAnnotationExample.swift +++ b/Apps/Examples/Examples/All Examples/SelectAnnotationExample.swift @@ -22,7 +22,7 @@ public class SelectAnnotationExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions()) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -30,8 +30,8 @@ public class SelectAnnotationExample: UIViewController, ExampleProtocol { let centerCoordinate = CLLocationCoordinate2D(latitude: 63.982738, longitude: -16.741790) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 12.0) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 12.0)) // Allow the view controller to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/SnapshotterCoreGraphicsExample.swift b/Apps/Examples/Examples/All Examples/SnapshotterCoreGraphicsExample.swift index 82b958f58b3..4aab3e7e39a 100644 --- a/Apps/Examples/Examples/All Examples/SnapshotterCoreGraphicsExample.swift +++ b/Apps/Examples/Examples/All Examples/SnapshotterCoreGraphicsExample.swift @@ -15,7 +15,7 @@ public class SnapshotterCoreGraphicsExample: UIViewController, ExampleProtocol { // TODO: Fix crash that occurs when omitting MapViewController. let testRect = CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height) - mapView = MapView(with: testRect, resourceOptions: resourceOptions()) + mapView = MapView(frame: testRect, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] // Add the `UIImageView` that will eventually render the snapshot. @@ -34,7 +34,7 @@ public class SnapshotterCoreGraphicsExample: UIViewController, ExampleProtocol { height: view.bounds.height), resourceOptions: resourceOptions) snapshotter = Snapshotter(options: options) - snapshotter.style.styleURI = .dark + snapshotter.style.uri = .dark snapshotter.on(.styleLoaded) { [weak self] _ in self?.startSnapshot() diff --git a/Apps/Examples/Examples/All Examples/SnapshotterExample.swift b/Apps/Examples/Examples/All Examples/SnapshotterExample.swift index f0c3c07a6e5..b584524b010 100644 --- a/Apps/Examples/Examples/All Examples/SnapshotterExample.swift +++ b/Apps/Examples/Examples/All Examples/SnapshotterExample.swift @@ -19,11 +19,11 @@ public class SnapshotterExample: UIViewController, ExampleProtocol { stackView.spacing = 12.0 let testRect = CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height / 2) - mapView = MapView(with: testRect, resourceOptions: resourceOptions()) + mapView = MapView(frame: testRect, resourceOptions: resourceOptions()) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - mapView.style.styleURI = .dark - mapView.cameraManager.setCamera(centerCoordinate: CLLocationCoordinate2D(latitude: 37.858, longitude: 138.472), - zoom: 3.5) + mapView.style.uri = .dark + mapView.cameraManager.setCamera(to: CameraOptions(center: CLLocationCoordinate2D(latitude: 37.858, longitude: 138.472), + zoom: 3.5)) // Add the `MapViewController`'s view to the stack view as a // child view controller. @@ -42,7 +42,7 @@ public class SnapshotterExample: UIViewController, ExampleProtocol { height: view.bounds.height / 2), resourceOptions: resourceOptions()) snapshotter = Snapshotter(options: options) - snapshotter.style.styleURI = .light + snapshotter.style.uri = .light snapshotter.camera = mapView.camera snapshotter.on(.styleLoaded) { [weak self] _ in diff --git a/Apps/Examples/Examples/All Examples/SwiftUIExample.swift b/Apps/Examples/Examples/All Examples/SwiftUIExample.swift index 97e08ad042f..088ce5dbffb 100644 --- a/Apps/Examples/Examples/All Examples/SwiftUIExample.swift +++ b/Apps/Examples/Examples/All Examples/SwiftUIExample.swift @@ -75,7 +75,7 @@ internal struct SwiftUIMapView: UIViewRepresentable { /// This method should create the `MapView`, and make sure that it is configured to be in sync /// with the current settings of `SwiftUIMapView` (in this example, just the `camera` and `styleURI`). func makeUIView(context: UIViewRepresentableContext) -> MapView { - let mapView = MapView(with: .zero, resourceOptions: resourceOptions) + let mapView = MapView(frame: .zero, resourceOptions: resourceOptions) updateUIView(mapView, context: context) /// Additionally, this is your opportunity to connect the coordinator to the map view. In this example @@ -89,13 +89,12 @@ internal struct SwiftUIMapView: UIViewRepresentable { /// If your `SwiftUIMapView` is reconfigured externally, SwiftUI will invoke `updateUIView(_:context:)` /// to give you an opportunity to re-sync the state of the underlying map view. func updateUIView(_ mapView: MapView, context: Context) { - mapView.cameraManager.setCamera(centerCoordinate: camera.center, - zoom: camera.zoom, + mapView.cameraManager.setCamera(to: CameraOptions(center: camera.center, zoom: camera.zoom), animated: false) /// Since changing the style causes annotations to be removed from the map /// we only call the setter if the value has changed. - if mapView.style.styleURI != styleURI { - mapView.style.styleURI = styleURI + if mapView.style.uri != styleURI { + mapView.style.uri = styleURI } /// The coordinator needs to manager annotations because diff --git a/Apps/Examples/Examples/All Examples/TerrainExample.swift b/Apps/Examples/Examples/All Examples/TerrainExample.swift index 99223a2146d..f40addbf2f6 100644 --- a/Apps/Examples/Examples/All Examples/TerrainExample.swift +++ b/Apps/Examples/Examples/All Examples/TerrainExample.swift @@ -15,7 +15,7 @@ public class TerrainExample: UIViewController, ExampleProtocol { let resourceOptions = ResourceOptions(accessToken: accessToken) - mapView = MapView(with: view.bounds, + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions, styleURI: .custom(url: URL(string: "mapbox://styles/mapbox-map-design/ckhqrf2tz0dt119ny6azh975y")!)) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] @@ -23,10 +23,10 @@ public class TerrainExample: UIViewController, ExampleProtocol { view.addSubview(mapView) let centerCoordinate = CLLocationCoordinate2D(latitude: 32.6141, longitude: -114.34411) - mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, - zoom: 13.1, - bearing: 80, - pitch: 85) + mapView.cameraManager.setCamera(to: CameraOptions(center: centerCoordinate, + zoom: 13.1, + bearing: 80, + pitch: 85)) mapView.on(.styleLoaded) { [weak self] _ in self?.addTerrain() diff --git a/Apps/Examples/Examples/All Examples/TrackingModeExample.swift b/Apps/Examples/Examples/All Examples/TrackingModeExample.swift index 8aa4be88b82..05d9921e384 100644 --- a/Apps/Examples/Examples/All Examples/TrackingModeExample.swift +++ b/Apps/Examples/Examples/All Examples/TrackingModeExample.swift @@ -13,7 +13,7 @@ public class TrackingModeExample: UIViewController, ExampleProtocol { override public func viewDidLoad() { super.viewDidLoad() - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions(), styleURI: StyleURI.streets) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions(), styleURI: StyleURI.streets) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(mapView) @@ -25,7 +25,7 @@ public class TrackingModeExample: UIViewController, ExampleProtocol { } // Set initial camera settings - mapView.cameraManager.setCamera(zoom: 15.0) + mapView.cameraManager.setCamera(to: CameraOptions(zoom: 15.0)) // Allows the delegate to receive information about map events. mapView.on(.mapLoaded) { [weak self] _ in @@ -49,6 +49,8 @@ public class CameraLocationConsumer: LocationConsumer { } public func locationUpdate(newLocation: Location) { - mapView?.cameraManager.setCamera(centerCoordinate: newLocation.coordinate, zoom: 15, animated: true, duration: 1.3) + mapView?.cameraManager.setCamera(to: CameraOptions(center: newLocation.coordinate, zoom: 15), + animated: true, + duration: 1.3) } } diff --git a/Apps/Examples/Examples/All Examples/UpdatePointAnnotationPositionExample.swift b/Apps/Examples/Examples/All Examples/UpdatePointAnnotationPositionExample.swift index 5e532afe4e0..2c0f9e22ad5 100644 --- a/Apps/Examples/Examples/All Examples/UpdatePointAnnotationPositionExample.swift +++ b/Apps/Examples/Examples/All Examples/UpdatePointAnnotationPositionExample.swift @@ -17,10 +17,10 @@ public class UpdatePointAnnotationPositionExample: UIViewController, ExampleProt } let resourceOptions = ResourceOptions(accessToken: accessToken) - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions) mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - mapView.cameraManager.setCamera(centerCoordinate: CLLocationCoordinate2D(latitude: 59.3, longitude: 8.06), - zoom: 12) + mapView.cameraManager.setCamera(to: CameraOptions(center: CLLocationCoordinate2D(latitude: 59.3, longitude: 8.06), + zoom: 12)) view.addSubview(mapView) // Allows the view controller to receive information about map events. diff --git a/Apps/StressTest/StressTest/ViewController.swift b/Apps/StressTest/StressTest/ViewController.swift index 405737fa211..8540ace89a7 100644 --- a/Apps/StressTest/StressTest/ViewController.swift +++ b/Apps/StressTest/StressTest/ViewController.swift @@ -80,7 +80,7 @@ class ViewController: UIViewController { // Do any additional setup after loading the view. resourceOptions = ResourceOptions(accessToken: AccountManager.shared.accessToken!) - mapView = MapView(with: view.bounds, resourceOptions: resourceOptions, styleURI: .streets) + mapView = MapView(frame: view.bounds, resourceOptions: resourceOptions, styleURI: .streets) view.addSubview(mapView) NSLayoutConstraint.activate([ mapView.leftAnchor.constraint(equalTo: view.leftAnchor), @@ -101,7 +101,7 @@ class ViewController: UIViewController { self.flyToNextCoordinate() } - mapView.style.styleURI = styles[styleStep].0 + mapView.style.uri = styles[styleStep].0 } func flyToNextCoordinate() { @@ -119,7 +119,7 @@ class ViewController: UIViewController { removeAnnotations() // Change the style - mapView.style.styleURI = styles[styleStep].0 + mapView.style.uri = styles[styleStep].0 print("Changing style to \(styles[styleStep].0)") return @@ -246,7 +246,8 @@ class ViewController: UIViewController { } do { - let jsonObject = try exp.jsonObject() + let data = try JSONEncoder().encode(exp.self) + let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) color = try mapView.__map.getStyleLayerProperty(forLayerId: land, property: "background-color") print("Setting background color expression") @@ -288,7 +289,7 @@ class ViewController: UIViewController { print("Creating snapshotter") let snapshotter = Snapshotter(options: options) - snapshotter.style.styleURI = .light + snapshotter.style.uri = .light snapshotter.camera = mapView.camera snapshotter.on(.styleLoaded) { [weak self] _ in diff --git a/CHANGELOG.md b/CHANGELOG.md index 71323c37799..06d066f03d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,42 @@ Mapbox welcomes participation and contributions from everyone. - `AnnotationManager` no longer conforms to `Observer` and no longer has a `peer` ([#246](https://github.com/mapbox/mapbox-maps-ios/pull/246)) - `AnnotationSupportableMap` is now internal ([#246](https://github.com/mapbox/mapbox-maps-ios/pull/246)) +- #### MapView + * Initializer has been changed to `public init(frame: CGRect, resourceOptions: ResourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions.default, styleURI: StyleURI? = .streets)`. + * `OrnamentSupportableMapView` is not internal. + +- #### Ornaments + * `LayoutPosition` has been deprecated in favor of `OrnamentPosition`. + * `LayoutVisibility` has been depracted in favor of `OrnamentVisibility`. + * `showsLogoView` has been renamed to `_showsLogoView`. + * `showsCompass` and `showsScale` have been deprecated. Visibility properties can be used to set how the Compass and Scale Bar should be shown. + +- #### Foundation + * `cancelTransitions` has been renamed to `cancelAnimations`. + * [`setCamera()`](https://github.com/mapbox/mapbox-maps-ios/pull/250/files#diff-8fa667141ac423a208a6e7036ed759e7e52fc6940bd58834c1935c2c6ead9c65L177) with individual parameters has been deprecated in favor of [`setCamera(to targetCamera: CameraOptions...)`](https://github.com/mapbox/mapbox-maps-ios/blob/edbf08e37975c81c7ee1cbc4bb046c48d522d306/Sources/MapboxMaps/Foundation/Camera/CameraManager.swift#L140) which requires `CameraOptions`. + * The following camera convenience functions have been removed: + * `public func transitionCoordinateBounds(newCoordinateBounds: CoordinateBounds, animated: Bool = false)` + * `public func transitionCoordinateBounds(to newCoordinateBounds: CoordinateBounds, edgePadding: UIEdgeInsets, animated: Bool = false, completion: ((UIViewAnimatingPosition) -> Void)? = nil)` + * `public func transitionVisibleCoordinates(newCoordinates: [CLLocationCoordinate2D], edgePadding: UIEdgeInsets, animated: Bool = false)` + * `public func transitionVisibleCoordinates(to newCoordinates: [CLLocationCoordinate2D], edgePadding: UIEdgeInsets, bearing: CLLocationDirection, duration: TimeInterval, animated: Bool = false, completion: ((UIViewAnimatingPosition) -> Void)? = nil)` + * `public func resetPosition()` + * `public func resetNorth(_ animated: Bool = false)` + * In `CameraAnimator`, `fractionComplete` is now of type `Double` and `delayFactor` now returns a `Double`. + * `MapboxLogoView` has been renamed to `LogoView`. + * `MapboxLogoSize` has been renamed to `LogoSize`. + +- #### Style + * Initializer is now marked as internal. + * `styleUri` has been renamed to `uri`. + * The `url` property from `StyleURL` has been removed. + +- #### Expressions + * `init(from: jsonObject)` and `public func jsonObject()` have been removed. + * `Element.op` has been renamed to `Element.operator`. + * `Argument.array` has been renamed to `Argument.numberArray`. + * `ValidExpressionArgument` has been renamed to `ExpressionArgumentConvertible` + + ### Bug fixes 🐞 - Fixes an issue that could cause issues with annotations including causing them to not be selectable ([#246](https://github.com/mapbox/mapbox-maps-ios/pull/246)) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index c74270c1e5f..dd533068ada 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ 07BA35E825157A0E003E1B55 /* AnnotationSupportableMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BA35E625157A0E003E1B55 /* AnnotationSupportableMap.swift */; }; 07D2C7DB2523EBE60025C2BA /* PolygonAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07D2C7DA2523EBE60025C2BA /* PolygonAnnotation.swift */; }; 07D7150425798CD70025BF61 /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07D7150325798CD70025BF61 /* UIImage.swift */; }; - 07D71591257994430025BF61 /* MapboxLogoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07D71590257994430025BF61 /* MapboxLogoView.swift */; }; 07E816DA256D72E500ACFA73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 07182014256C1F6100F22489 /* Assets.xcassets */; }; 0C01C0B925486E7200E4AA46 /* ExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C01C08825486E6100E4AA46 /* ExpressionTests.swift */; }; 0C1AF55C244DF500008D2A10 /* MapOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C1AF55B244DF500008D2A10 /* MapOptions.swift */; }; @@ -111,7 +110,6 @@ 0C9DE3B3252C2A1F00880CC8 /* GeoJSONSourceDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9DE382252C299800880CC8 /* GeoJSONSourceDataTests.swift */; }; 0CA3DD61257AAE3B00B12C8F /* SkyLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA3DD5E257AAE3B00B12C8F /* SkyLayer.swift */; }; 0CAC3CAA2534E8CC00D031E7 /* ResourceOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAC3CA92534E8CC00D031E7 /* ResourceOptions.swift */; }; - 0CAC3CC32534E90500D031E7 /* MapSnapshotOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAC3CC22534E90500D031E7 /* MapSnapshotOptions.swift */; }; 0CBCF28E25409F030025F7B3 /* ResolvedImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CBCF28D25409F030025F7B3 /* ResolvedImage.swift */; }; 0CC6EF0B25C3263400BFB153 /* ModelLayerIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC6EEFC25C3263400BFB153 /* ModelLayerIntegrationTests.swift */; }; 0CC6EF0E25C3263400BFB153 /* BackgroundLayerIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC6EEFD25C3263400BFB153 /* BackgroundLayerIntegrationTests.swift */; }; @@ -164,8 +162,6 @@ 2B8637E62463F36400698135 /* DistanceFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B8637D72461992200698135 /* DistanceFormatter.swift */; }; 5A35924524644C5E00E67344 /* CompassDirectionFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A359243246448E600E67344 /* CompassDirectionFormatter.swift */; }; 5A3592B3246C1FA000E67344 /* MapboxInfoButtonOrnament.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A3592AC246AD45500E67344 /* MapboxInfoButtonOrnament.swift */; }; - 5A3593B6247FD9AD00E67344 /* LayoutVisibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A3593B5247FD9AC00E67344 /* LayoutVisibility.swift */; }; - 5A3593B9247FDA4800E67344 /* LayoutPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A3593B8247FDA4800E67344 /* LayoutPosition.swift */; }; 5A9648FE246429C3001FF05D /* MapboxCompassOrnamentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A9648FC2462F07B001FF05D /* MapboxCompassOrnamentView.swift */; }; B506A5A025E023E90097ADB7 /* Bundle+MapboxMapsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B506A59E25E023E90097ADB7 /* Bundle+MapboxMapsTests.swift */; }; B506A5A125E023E90097ADB7 /* Bundle+MapboxMapsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B506A59E25E023E90097ADB7 /* Bundle+MapboxMapsTests.swift */; }; @@ -201,6 +197,7 @@ C69F0142254358B3001AB49B /* LocationManagerIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69F011125431AF4001AB49B /* LocationManagerIntegrationTests.swift */; }; C69F015A254358C5001AB49B /* AnnotationManagerIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07958C23253A2AE50043ECC0 /* AnnotationManagerIntegrationTests.swift */; }; C69F017525435C55001AB49B /* LocationProviderMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69F017325435C55001AB49B /* LocationProviderMock.swift */; }; + C6F256EF261FB99C0093D353 /* LogoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F256EE261FB99C0093D353 /* LogoView.swift */; }; CA0492D6261382E900CF458A /* StyleURI.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA0492D5261382E900CF458A /* StyleURI.swift */; }; CA050571259104E200FF7D02 /* FeatureQueryingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07B82A652548C1320048D0F2 /* FeatureQueryingTest.swift */; }; CA05A7202551C89600ABF902 /* CacheManagerIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA05A71E2551C89600ABF902 /* CacheManagerIntegrationTests.swift */; }; @@ -396,7 +393,6 @@ 07D2C7DA2523EBE60025C2BA /* PolygonAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolygonAnnotation.swift; sourceTree = ""; }; 07D2C80B2523ECC40025C2BA /* PolygonAnnotationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolygonAnnotationTests.swift; sourceTree = ""; }; 07D7150325798CD70025BF61 /* UIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImage.swift; sourceTree = ""; }; - 07D71590257994430025BF61 /* MapboxLogoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxLogoView.swift; sourceTree = ""; }; 07E4FD1A24E4A35600D734D1 /* MapboxMapsAnnotations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MapboxMapsAnnotations.h; sourceTree = ""; }; 07E4FD1B24E4A35600D734D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 07E4FD2724E4A35600D734D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -490,7 +486,6 @@ 0C9DE382252C299800880CC8 /* GeoJSONSourceDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeoJSONSourceDataTests.swift; sourceTree = ""; }; 0CA3DD5E257AAE3B00B12C8F /* SkyLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkyLayer.swift; sourceTree = ""; }; 0CAC3CA92534E8CC00D031E7 /* ResourceOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceOptions.swift; sourceTree = ""; }; - 0CAC3CC22534E90500D031E7 /* MapSnapshotOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapSnapshotOptions.swift; sourceTree = ""; }; 0CBCF28D25409F030025F7B3 /* ResolvedImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResolvedImage.swift; sourceTree = ""; }; 0CBCF2D7254229630025F7B3 /* STYLE_README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = STYLE_README.md; path = ../../../Mapbox/STYLE_README.md; sourceTree = ""; }; 0CC6EEFC25C3263400BFB153 /* ModelLayerIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelLayerIntegrationTests.swift; sourceTree = ""; }; @@ -572,8 +567,6 @@ 5A35924F246598F600E67344 /* CompassDirectionFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompassDirectionFormatterTests.swift; sourceTree = ""; }; 5A3592AC246AD45500E67344 /* MapboxInfoButtonOrnament.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxInfoButtonOrnament.swift; sourceTree = ""; }; 5A3593792476DEB800E67344 /* MapboxCompassOrnamentViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxCompassOrnamentViewTests.swift; sourceTree = ""; }; - 5A3593B5247FD9AC00E67344 /* LayoutVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutVisibility.swift; sourceTree = ""; }; - 5A3593B8247FDA4800E67344 /* LayoutPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutPosition.swift; sourceTree = ""; }; 5A9648FC2462F07B001FF05D /* MapboxCompassOrnamentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxCompassOrnamentView.swift; sourceTree = ""; }; A43D7B5125196D1C00951460 /* Annotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Annotation.swift; sourceTree = ""; }; A44EE617244ED578006FE97E /* QuickZoomGestureHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickZoomGestureHandlerTests.swift; sourceTree = ""; }; @@ -612,6 +605,7 @@ C64ED33B253F819B00ADADFB /* LocationConsumerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationConsumerMock.swift; sourceTree = ""; }; C69F011125431AF4001AB49B /* LocationManagerIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManagerIntegrationTests.swift; sourceTree = ""; }; C69F017325435C55001AB49B /* LocationProviderMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationProviderMock.swift; sourceTree = ""; }; + C6F256EE261FB99C0093D353 /* LogoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogoView.swift; sourceTree = ""; }; CA0492D5261382E900CF458A /* StyleURI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleURI.swift; sourceTree = ""; }; CA05A71E2551C89600ABF902 /* CacheManagerIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheManagerIntegrationTests.swift; sourceTree = ""; }; CA0B374325C4BEAE00B3396E /* MapboxMapsHTTPTestsWithHost.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapboxMapsHTTPTestsWithHost.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -884,9 +878,6 @@ children = ( 0C1AF55B244DF500008D2A10 /* MapOptions.swift */, 0C1AF564244F65E6008D2A10 /* OrnamentOptions.swift */, - 5A3593B5247FD9AC00E67344 /* LayoutVisibility.swift */, - 5A3593B8247FDA4800E67344 /* LayoutPosition.swift */, - 0CAC3CC22534E90500D031E7 /* MapSnapshotOptions.swift */, 0CC9937D25D46B7100650CC1 /* RenderOptions.swift */, ); path = Configuration; @@ -1118,12 +1109,12 @@ 1F11C1102421B05600F8397B /* MapboxMapsFoundation */ = { isa = PBXGroup; children = ( + C6F256EE261FB99C0093D353 /* LogoView.swift */, 07855E29258BFCD90060A870 /* Extensions */, 1F11C1112421B05600F8397B /* MapboxMapsFoundation.h */, 1F11C1122421B05600F8397B /* Info.plist */, 1F2AD70A2421BCBF006592F4 /* AccountManager.swift */, 0C95DBB8257A92F90018252C /* BaseMapView.swift */, - 07D71590257994430025BF61 /* MapboxLogoView.swift */, 07A0BC9D2582F15B00B8E109 /* GeoJSONManager.swift */, 1F4B7D7A2464C36E00745F05 /* Camera */, 07625BB42587F273002EEBCC /* Events */, @@ -1819,7 +1810,6 @@ 07980ECE251D5B5D00730DB7 /* LineAnnotation.swift in Sources */, 0742060024E4A598000A8932 /* AnnotationManager.swift in Sources */, 0C708F5324EB23C7003CE791 /* RasterSource.swift in Sources */, - 5A3593B9247FDA4800E67344 /* LayoutPosition.swift in Sources */, 0CE8ED6125890F870066E56C /* ModelSource.swift in Sources */, C64994A9258D5ADE0052C21C /* LocationPuckManager.swift in Sources */, 5A35924524644C5E00E67344 /* CompassDirectionFormatter.swift in Sources */, @@ -1850,7 +1840,6 @@ CA0492D6261382E900CF458A /* StyleURI.swift in Sources */, 0C708F5924EB2927003CE791 /* Sources.swift in Sources */, 0C708F2524EB1EE2003CE791 /* HillshadeLayer.swift in Sources */, - 0CAC3CC32534E90500D031E7 /* MapSnapshotOptions.swift in Sources */, 0C708F2124EB1EE2003CE791 /* FillExtrusionLayer.swift in Sources */, 0C26425524EECD14001FE2E3 /* AllExpressions.swift in Sources */, 0782B1A3258C250400D5FCE5 /* Geometry.swift in Sources */, @@ -1863,6 +1852,7 @@ 0C3B1E9224DDADD000CC29E8 /* MapboxMobileEvents+TelemetryProtocol.swift in Sources */, 0C9640E12531056700CABD3E /* LocationConsumer.swift in Sources */, 0C708F4D24EB23C7003CE791 /* RasterDemSource.swift in Sources */, + C6F256EF261FB99C0093D353 /* LogoView.swift in Sources */, 0CD62F23245887C8006421D1 /* OrnamentsManager.swift in Sources */, CA0C427E2602BECE0054D9D0 /* LayerPosition.swift in Sources */, 07A0BCCB2582F16300B8E109 /* GeoJSONManager.swift in Sources */, @@ -1895,7 +1885,6 @@ B5B55D45260E4D1500EBB589 /* AnimationOwner.swift in Sources */, 0CD34FE8242AAE0900943687 /* MapView+Managers.swift in Sources */, B5B55D44260E4D1500EBB589 /* CameraAnimator.swift in Sources */, - 5A3593B6247FD9AD00E67344 /* LayoutVisibility.swift in Sources */, 0CD62F12245885AA006421D1 /* AccountManager.swift in Sources */, 5A9648FE246429C3001FF05D /* MapboxCompassOrnamentView.swift in Sources */, 0C8AA1F3257FE1830037FD6B /* MapEvents.swift in Sources */, @@ -1932,7 +1921,6 @@ 1FECC9E02474519D00B63910 /* Expression.swift in Sources */, B52050A8260538240003E5BB /* ModelLayer.swift in Sources */, 0CD62F1124588532006421D1 /* GestureHandlerDelegate.swift in Sources */, - 07D71591257994430025BF61 /* MapboxLogoView.swift in Sources */, 0782B061258C16B200D5FCE5 /* Utils.swift in Sources */, 0CD62F2C24588937006421D1 /* Style.swift in Sources */, 0CAC3CAA2534E8CC00D031E7 /* ResourceOptions.swift in Sources */, diff --git a/Sources/MapboxMaps/Annotations/AnnotationSupportableMap.swift b/Sources/MapboxMaps/Annotations/AnnotationSupportableMap.swift index dd4dc92d0b9..2ea22b426bf 100644 --- a/Sources/MapboxMaps/Annotations/AnnotationSupportableMap.swift +++ b/Sources/MapboxMaps/Annotations/AnnotationSupportableMap.swift @@ -50,7 +50,7 @@ extension BaseMapView: AnnotationSupportableMap { if let exp = filter { do { - jsonExpression = try exp.jsonObject() + jsonExpression = try jsonObject(exp: exp) } catch { completion(.failure(.invalidFilter(error))) return @@ -101,7 +101,7 @@ extension BaseMapView: AnnotationSupportableMap { if let exp = filter { do { - jsonExpression = try exp.jsonObject() + jsonExpression = try jsonObject(exp: exp) } catch { completion(.failure(.invalidFilter(error))) return @@ -131,4 +131,10 @@ extension BaseMapView: AnnotationSupportableMap { } }) } + + private func jsonObject(exp: Expression) throws -> Any { + let data = try JSONEncoder().encode(exp.self) + let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) + return jsonObject + } } diff --git a/Sources/MapboxMaps/Foundation/BaseMapView.swift b/Sources/MapboxMaps/Foundation/BaseMapView.swift index 6bb57573698..b17897bd66d 100644 --- a/Sources/MapboxMaps/Foundation/BaseMapView.swift +++ b/Sources/MapboxMaps/Foundation/BaseMapView.swift @@ -88,9 +88,9 @@ open class BaseMapView: UIView, MapClient, MBMMetalViewProvider, CameraViewDeleg /// List of completion blocks that need to be completed by the displayLink internal var pendingAnimatorCompletionBlocks: [PendingAnimationCompletion] = [] - public var needsDisplayRefresh: Bool = false - public var dormant: Bool = false - public var displayCallback: (() -> Void)? + internal var needsDisplayRefresh: Bool = false + internal var dormant: Bool = false + internal var displayCallback: (() -> Void)? private var observerConcrete: ObserverConcrete! @objc dynamic internal var displayLink: CADisplayLink? @@ -197,7 +197,7 @@ open class BaseMapView: UIView, MapClient, MBMMetalViewProvider, CameraViewDeleg } // MARK: Init - public init(with frame: CGRect, resourceOptions: ResourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions, styleURI: URL?) { + public init(frame: CGRect, resourceOptions: ResourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions, styleURI: URL?) { super.init(frame: frame) self.commonInit(resourceOptions: resourceOptions, glyphsRasterizationOptions: glyphsRasterizationOptions, diff --git a/Sources/MapboxMaps/Foundation/Camera/CameraAnimator.swift b/Sources/MapboxMaps/Foundation/Camera/CameraAnimator.swift index f7f00452cdb..1de6d45d5c6 100644 --- a/Sources/MapboxMaps/Foundation/Camera/CameraAnimator.swift +++ b/Sources/MapboxMaps/Foundation/Camera/CameraAnimator.swift @@ -32,9 +32,9 @@ public class CameraAnimator: NSObject { } /// Value that represents what percentage of the animation has been completed. - public var fractionComplete: CGFloat { - get { return propertyAnimator.fractionComplete } - set { propertyAnimator.fractionComplete = newValue } + public var fractionComplete: Double { + get { return Double(propertyAnimator.fractionComplete) } + set { propertyAnimator.fractionComplete = CGFloat(newValue) } } // MARK: Initializer @@ -75,9 +75,9 @@ public class CameraAnimator: NSObject { } /// Add animations block to the animator with a `delayFactor`. - public func addAnimations(_ animations: @escaping () -> Void, delayFactor: CGFloat) { + public func addAnimations(_ animations: @escaping () -> Void, delayFactor: Double) { // if this cameraAnimator is not in the list of CameraAnimators held by the `CameraManager` then add it to that list - propertyAnimator.addAnimations(animations, delayFactor: delayFactor) + propertyAnimator.addAnimations(animations, delayFactor: CGFloat(delayFactor)) } /// Add animations block to the animator. @@ -94,7 +94,7 @@ public class CameraAnimator: NSObject { } /// Continue the animation with a timing parameter (`UITimingCurveProvider`) and duration factor (`CGFloat`). - public func continueAnimation(withTimingParameters parameters: UITimingCurveProvider?, durationFactor: CGFloat) { - propertyAnimator.continueAnimation(withTimingParameters: parameters, durationFactor: durationFactor) + public func continueAnimation(withTimingParameters parameters: UITimingCurveProvider?, durationFactor: Double) { + propertyAnimator.continueAnimation(withTimingParameters: parameters, durationFactor: CGFloat(durationFactor)) } } diff --git a/Sources/MapboxMaps/Foundation/Camera/CameraManager.swift b/Sources/MapboxMaps/Foundation/Camera/CameraManager.swift index 9df0526f085..731c23f37cb 100644 --- a/Sources/MapboxMaps/Foundation/Camera/CameraManager.swift +++ b/Sources/MapboxMaps/Foundation/Camera/CameraManager.swift @@ -1,4 +1,3 @@ -// swiftlint:disable file_length type_body_length import UIKit import Turf @@ -20,7 +19,12 @@ public class CameraManager { } /// Pointer HashTable for holding camera animators - public internal(set) var cameraAnimators = NSHashTable.weakObjects() + internal var cameraAnimators = NSHashTable.weakObjects() + + /// List of animators currently alive + public var cameraAnimatorsList: [CameraAnimator] { + return cameraAnimators.allObjects + } /// Internal camera animator used for animated transition internal var internalCameraAnimator: CameraAnimator? @@ -28,7 +32,7 @@ public class CameraManager { /// May want to convert to an enum. fileprivate let northBearing: CGFloat = 0 - public weak var mapView: BaseMapView? + internal weak var mapView: BaseMapView? public init(for mapView: BaseMapView, with mapCameraOptions: MapCameraOptions) { self.mapView = mapView @@ -133,7 +137,10 @@ public class CameraManager { /// - animated: Set to `true` if transition should be animated. `false` by default. /// - duration: Controls the duration of the animation transition. Must be greater than zero if `animated` is true. /// - completion: The completion block to be called after an animated transition. Only called if `animated` is true. - public func setCamera(to targetCamera: CameraOptions, animated: Bool = false, duration: TimeInterval = 0, completion: ((UIViewAnimatingPosition) -> Void)? = nil) { + public func setCamera(to targetCamera: CameraOptions, + animated: Bool = false, + duration: TimeInterval = 0, + completion: ((UIViewAnimatingPosition) -> Void)? = nil) { guard let mapView = mapView else { assertionFailure("MapView is nil.") return @@ -162,39 +169,7 @@ public class CameraManager { } } - /// Transition the camera view to a new map camera based on individual camera properties, - /// optionally animating the change and executing a completion block after the transition occurs. - /// - Parameters: - /// - centerCoordinate: The new center coordinate the viewport will transition to. - /// - padding: The new edge insets the viewport will use to to apply padding. - /// - anchor: The new anchor point the viewport will use. - /// - zoom: The new zoom level the viewport will transition to. - /// - bearing: The bearing the viewport will rotate to. - /// - pitch: The new pitch the viewport will transition to. - /// - animated: A boolean indicating if the change should be animated. By default, this value is `false` - /// - duration: The `TimeInterval` for the animation to be completed - /// - completion: The completion block to execute after the transition has occurred. - public func setCamera(centerCoordinate: CLLocationCoordinate2D? = nil, - padding: UIEdgeInsets? = nil, - anchor: CGPoint? = nil, - zoom: CGFloat? = nil, - bearing: CLLocationDirection? = nil, - pitch: CGFloat? = nil, - animated: Bool = false, - duration: TimeInterval = 0, - completion: ((UIViewAnimatingPosition) -> Void)? = nil) { - let newCamera = CameraOptions(center: centerCoordinate, - padding: padding, - anchor: anchor, - zoom: zoom, - bearing: bearing, - pitch: pitch) - - setCamera(to: newCamera, animated: animated, duration: duration, completion: completion) - } - // swiftlint:enable function_parameter_count - - public func cancelTransitions() { + public func cancelAnimations() { for animator in cameraAnimators.allObjects where animator.state == .active { animator.stopAnimation() } @@ -226,128 +201,6 @@ public class CameraManager { internalCameraAnimator?.startAnimation() } - /// Reset the map's camera to the default style camera. - public func resetPosition() { - guard let mapView = mapView else { - assertionFailure("MapView is nil.") - return - } - - let defaultOptions = try! mapView.__map.getStyleDefaultCamera() - setCamera(to: defaultOptions, completion: nil) - } - - /// Resets the map rotation to a north bearing of `0` degrees. - /// - Parameter animated: A boolean indicating if the change should be animated. By default, this value is `false`. - public func resetNorth(_ animated: Bool = false) { - setCamera(bearing: CLLocationDirection(northBearing), - animated: animated) - } - - // MARK: Fitting the camera specified regions - - /// Transitions the viewport to fit a given set of new coordinate bounds, - /// optionally animating the change. - /// - /// This method also accounts for any `UIEdgeInsets` that may have been set - /// through the the `CameraView`'s `padding` property. - /// - Parameters: - /// - newCoordinateBounds: The coordinate bounds that will be displayed within the viewport. - /// - animated: A boolean indicating if the change should be animated. Defaults to `false`. - public func transitionCoordinateBounds(newCoordinateBounds: CoordinateBounds, - animated: Bool = false) { - transitionCoordinateBounds(to: newCoordinateBounds, - edgePadding: UIEdgeInsets.zero, - animated: animated, - completion: nil) - } - - /// Transitions the viewport to fit a given set of new coordinate bounds, - /// specifying a custom edge padding, an optional animation change, and an optional - /// completion block to execute after the transition occurs. - /// - /// - Parameters: - /// - newCoordinateBounds: The new coordinate bounds that will be displayed within the viewport. - /// - edgePadding: The padding the viewport will adjust itself by after transitioning to the new viewport. - /// - animated: A boolean indicating if the change should be animated. Defaults to `false`. - /// - completion: An optional function to execute after the transition has occurred. - public func transitionCoordinateBounds(to newCoordinateBounds: CoordinateBounds, - edgePadding: UIEdgeInsets, - animated: Bool = false, - completion: ((UIViewAnimatingPosition) -> Void)? = nil) { - let southeast = CLLocationCoordinate2D(latitude: newCoordinateBounds.northeast.latitude, - longitude: newCoordinateBounds.southwest.longitude) - let southwest = newCoordinateBounds.southwest - let northwest = CLLocationCoordinate2D(latitude: newCoordinateBounds.southwest.latitude, - longitude: newCoordinateBounds.northeast.longitude) - let northeast = newCoordinateBounds.northeast - - transitionVisibleCoordinates(to: [southeast, southwest, northwest, northeast], - edgePadding: edgePadding, - bearing: 0, - duration: 0, - animated: animated, - completion: completion) - } - - /// Transitions the viewport to fit a given array of new coordinates, specifying - /// a custom edge padding an optional animation change. - /// - /// - Parameters: - /// - newCoordinates: The coordinate bounds that will be displayed within the viewport. - /// - edgePadding: The padding the viewport will adjust itself by after transitioning to the new viewport. - /// - animated: A boolean indicating if the change should be animated. Defaults to `false`. - - public func transitionVisibleCoordinates(newCoordinates: [CLLocationCoordinate2D], - edgePadding: UIEdgeInsets, - animated: Bool = false) { - transitionVisibleCoordinates(to: newCoordinates, - edgePadding: edgePadding, - bearing: 0, - duration: 0, - animated: animated, - completion: nil) - } - - /// Transitions the viewport to fit a given array of new coordinates, specifying - /// a custom edge padding, an optional animation change, and an optional - /// completion block to execute after the transition occurs. - /// - /// - Parameters: - /// - newCoordinates: The array of coordinates that will be displayed within the viewport. - /// - edgePadding: The padding the viewport will adjust itself by after transitioning to the new viewport. - /// - bearing: The bearing the viewport will adjust itself after transitioning to the new viewport - /// - animated: A boolean indicating if the change should be animated. Defaults to `false`. - /// - completion: An optional closure to execute after the transition has occurred. - - public func transitionVisibleCoordinates(to newCoordinates: [CLLocationCoordinate2D], - edgePadding: UIEdgeInsets, - bearing: CLLocationDirection, - duration: TimeInterval, - animated: Bool = false, - completion: ((UIViewAnimatingPosition) -> Void)? = nil) { - guard let mapView = mapView else { - assertionFailure("MapView is nil.") - return - } - - // Don't set visible coordinate bounds if the coordinates are - // outside of the range of bounds specified in the MapCameraOptions. - if mapCameraOptions.restrictedCoordinateBounds?.contains(newCoordinates) == false { return } - - let padding = edgePadding.toMBXEdgeInsetsValue() - let bearing = bearing >= 0 ? CLLocationDirection(CGFloat(bearing)) : mapView.bearing - let coordinates = newCoordinates.map { CLLocation(latitude: $0.latitude, longitude: $0.longitude)} - let pitch = mapView.pitch - - let cameraOptions = try! mapView.__map.cameraForCoordinates(forCoordinates: coordinates, - padding: padding, - bearing: NSNumber(value: Float(bearing)), - pitch: NSNumber(value: Float(pitch))) - - setCamera(to: cameraOptions, animated: animated, duration: duration, completion: completion) - } - /// Moves the viewpoint to a different location using a transition animation that /// evokes powered flight and an optional transition duration and timing function /// It seamlessly incorporates zooming and panning to help diff --git a/Sources/MapboxMaps/Foundation/Camera/CameraOptions.swift b/Sources/MapboxMaps/Foundation/Camera/CameraOptions.swift index 55b57bddf73..a179299660b 100644 --- a/Sources/MapboxMaps/Foundation/Camera/CameraOptions.swift +++ b/Sources/MapboxMaps/Foundation/Camera/CameraOptions.swift @@ -2,7 +2,7 @@ import Foundation import CoreLocation import UIKit -public extension CameraOptions { +extension CameraOptions { /** The `CameraOptions` object contains information about the current state of the camera. @@ -17,12 +17,12 @@ public extension CameraOptions { - Returns: A `CameraOptions` object that contains all configuration information the `CameraView` will use to render the map's viewport. */ - convenience init(center: CLLocationCoordinate2D? = nil, - padding: UIEdgeInsets? = nil, - anchor: CGPoint? = nil, - zoom: CGFloat? = nil, - bearing: CLLocationDirection? = nil, - pitch: CGFloat? = nil) { + public convenience init(center: CLLocationCoordinate2D? = nil, + padding: UIEdgeInsets? = nil, + anchor: CGPoint? = nil, + zoom: CGFloat? = nil, + bearing: CLLocationDirection? = nil, + pitch: CGFloat? = nil) { self.init(__center: center?.location, padding: padding?.toMBXEdgeInsetsValue(), anchor: anchor?.screenCoordinate, @@ -31,7 +31,7 @@ public extension CameraOptions { pitch: pitch?.NSNumber) } - var center: CLLocationCoordinate2D? { + public var center: CLLocationCoordinate2D? { get { return __center?.coordinate } @@ -40,7 +40,7 @@ public extension CameraOptions { } } - var padding: UIEdgeInsets? { + public var padding: UIEdgeInsets? { get { return __padding?.toUIEdgeInsetsValue() } @@ -49,7 +49,7 @@ public extension CameraOptions { } } - var anchor: CGPoint? { + public var anchor: CGPoint? { get { return __anchor?.point } @@ -58,7 +58,7 @@ public extension CameraOptions { } } - var zoom: CGFloat? { + public var zoom: CGFloat? { get { return __zoom?.CGFloat } @@ -67,7 +67,7 @@ public extension CameraOptions { } } - var bearing: CLLocationDirection? { + public var bearing: CLLocationDirection? { get { return __bearing?.CLLocationDirection } @@ -76,7 +76,7 @@ public extension CameraOptions { } } - var pitch: CGFloat? { + public var pitch: CGFloat? { get { return __pitch?.CGFloat } @@ -84,9 +84,8 @@ public extension CameraOptions { __pitch = newValue?.NSNumber } } -} -extension CameraOptions { + // MARK: Equals function public static func == (lhs: CameraOptions, rhs: CameraOptions) -> Bool { return lhs.center == rhs.center && lhs.padding == rhs.padding && diff --git a/Sources/MapboxMaps/Foundation/Events/Event.swift b/Sources/MapboxMaps/Foundation/Events/Event.swift index befe34e3eb9..5959fcb3904 100644 --- a/Sources/MapboxMaps/Foundation/Events/Event.swift +++ b/Sources/MapboxMaps/Foundation/Events/Event.swift @@ -2,7 +2,7 @@ import Foundation internal typealias EventAttributes = [String: Any] -public enum EventType { +internal enum EventType { case custom(name: String) case map(event: Maps) case metrics(event: Metrics) @@ -10,27 +10,23 @@ public enum EventType { case offlineStorage(event: OfflineStorage) case memoryWarning - public enum Maps { + internal enum Maps { case loaded } - public enum Metrics { + internal enum Metrics { case performance(metrics: [String: Any]) } - public enum Snapshot { + internal enum Snapshot { case initialized } - public enum OfflineStorage { + internal enum OfflineStorage { case downloadStarted(attributes: [String: Any]) } } -public protocol EventsEmitter { - var eventsListener: EventsListener! { get set } -} - -public protocol EventsListener: AnyObject { +internal protocol EventsListener: AnyObject { func push(event: EventType) } diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/GlyphsRasterizationOptions.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/GlyphsRasterizationOptions.swift index e953a55a642..f13300ff6fa 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/GlyphsRasterizationOptions.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/GlyphsRasterizationOptions.swift @@ -1,17 +1,17 @@ import Foundation import MapboxCoreMaps -public extension GlyphsRasterizationOptions { +extension GlyphsRasterizationOptions { /// Default fallback font - static var fallbackFontFamilyName: String = { + internal static var fallbackFontFamilyName: String = { UIFont.systemFont(ofSize: 0, weight: .regular).familyName }() /// Default GlyphsRasterizationOptions. RasterizationMode defaults to /// `.ideographsRasterizedLocally` i.e. ideographic symbols are rasterized locally (not loaded /// from the server) using an appropriate system font. - static var `default`: GlyphsRasterizationOptions = { + public static var `default`: GlyphsRasterizationOptions = { GlyphsRasterizationOptions(rasterizationMode: .ideographsRasterizedLocally) }() @@ -20,8 +20,8 @@ public extension GlyphsRasterizationOptions { /// - rasterizationMode: Rasterization mode /// - fontFamilies: Array of fonts, used for glyph rendering. Defaults to an appropriate /// system font - convenience init(rasterizationMode: GlyphsRasterizationMode, - fontFamilies: [String] = []) { + public convenience init(rasterizationMode: GlyphsRasterizationMode, + fontFamilies: [String] = []) { let fontFamilies = fontFamilies.isEmpty ? Self.fallbackFontFamilyName : fontFamilies.joined(separator: "\n") self.init(rasterizationMode: rasterizationMode, fontFamily: fontFamilies) } diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/LayerPosition.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/LayerPosition.swift index ed9cc6748b9..103bcb8ac4e 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/LayerPosition.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/LayerPosition.swift @@ -1,12 +1,22 @@ import MapboxCoreMaps -public extension LayerPosition { +extension LayerPosition { + + /// Convenience initializer for LayerPosition + /// - Parameters: + /// - above: Layer should be positioned above specified layer id + /// - below: Layer should be positioned below specified layer id + /// - at: Layer should be positioned at specified index in a layers stack + public convenience init(above: String? = nil, below: String? = nil, at: Int? = nil) { + self.init(__above: above, below: below, at: at?.NSNumber) + } + /// Layer should be positioned at a specified index in the layers stack - var at: UInt32? { + public var at: UInt32? { return __at?.uint32Value } - override func isEqual(_ object: Any?) -> Bool { + public override func isEqual(_ object: Any?) -> Bool { guard let object = object as? LayerPosition else { return false } diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/MBXEdgeInsets.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/MBXEdgeInsets.swift index e8d678c9a02..b0208864f6d 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/MBXEdgeInsets.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/MBXEdgeInsets.swift @@ -1,6 +1,6 @@ import Foundation -public extension EdgeInsets { +internal extension EdgeInsets { func toUIEdgeInsetsValue() -> UIEdgeInsets { return UIEdgeInsets(top: CGFloat(self.top), left: CGFloat(self.left), @@ -9,7 +9,7 @@ public extension EdgeInsets { } } -public extension UIEdgeInsets { +internal extension UIEdgeInsets { func toMBXEdgeInsetsValue() -> EdgeInsets { return EdgeInsets(top: Double(self.top), left: Double(self.left), diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/ResourceOptions.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/ResourceOptions.swift index 96731c15a8d..5f78e2883c1 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/ResourceOptions.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/ResourceOptions.swift @@ -2,16 +2,25 @@ import Foundation // MARK: - ResourceOptions -public extension ResourceOptions { - convenience init(accessToken: String, - baseUrl: String? = nil, - cachePath: String? = nil, - assetPath: String? = nil, - tileStorePath: String? = nil, - loadTilePacksFromNetwork: NSNumber? = nil, - cacheSize: UInt64 = (1024*1024*10)) { - - let cacheURL = ResourceOptions.cacheURLIncludingSubdirectory(useSubdirectory: true) +extension ResourceOptions { + /// Intializer for `ResourceOptions` + /// - Parameters: + /// - accessToken: Your mapbox access API token. + /// - baseUrl: The base URL. + /// - cachePath: The path to the cache. + /// - assetPath: The path to the assets. + /// - tileStorePath: The path to the tile store. + /// - loadTilePacksFromNetwork: Detemines if tiles pack should or should not be avoided from the network. + /// - cacheSize: The size of the cache. + public convenience init(accessToken: String, + baseUrl: String? = nil, + cachePath: String? = nil, + assetPath: String? = nil, + tileStorePath: String? = nil, + loadTilePacksFromNetwork: NSNumber? = nil, + cacheSize: UInt64 = (1024*1024*10)) { + + let cacheURL = ResourceOptions.cacheURLIncludingSubdirectory() let resolvedCachePath = cachePath == nil ? cacheURL?.path : cachePath self.init(__accessToken: accessToken, baseURL: baseUrl, @@ -22,42 +31,36 @@ public extension ResourceOptions { cacheSize: NSNumber(value: cacheSize)) } - var cacheSize: UInt64? { + public var cacheSize: UInt64? { __cacheSize?.uint64Value } - static func cacheURLIncludingSubdirectory(useSubdirectory: Bool) -> URL? { - guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return nil } - - var cacheDirectoryURL: URL - do { - cacheDirectoryURL = try FileManager.default.url(for: .applicationSupportDirectory, - in: .userDomainMask, - appropriateFor: nil, - create: true) - } catch { - return nil - } - - cacheDirectoryURL = cacheDirectoryURL.appendingPathComponent(bundleIdentifier) - - if useSubdirectory { - cacheDirectoryURL.appendPathComponent(".mapbox") - } - - do { - try FileManager.default.createDirectory(at: cacheDirectoryURL, - withIntermediateDirectories: true, - attributes: nil) - } catch { - return nil - } - - if useSubdirectory { - cacheDirectoryURL.setTemporaryResourceValue(true, forKey: .isExcludedFromBackupKey) - } - - return cacheDirectoryURL.appendingPathComponent("cache.db") + private static func cacheURLIncludingSubdirectory() -> URL? { + guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return nil } + + var cacheDirectoryURL: URL + do { + cacheDirectoryURL = try FileManager.default.url(for: .applicationSupportDirectory, + in: .userDomainMask, + appropriateFor: nil, + create: true) + } catch { + return nil } + cacheDirectoryURL = cacheDirectoryURL.appendingPathComponent(bundleIdentifier) + cacheDirectoryURL.appendPathComponent(".mapbox") + + do { + try FileManager.default.createDirectory(at: cacheDirectoryURL, + withIntermediateDirectories: true, + attributes: nil) + } catch { + return nil + } + + cacheDirectoryURL.setTemporaryResourceValue(true, forKey: .isExcludedFromBackupKey) + + return cacheDirectoryURL.appendingPathComponent("cache.db") + } } diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/ScreenCoordinate.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/ScreenCoordinate.swift index d6293a3868c..af65d40a333 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/ScreenCoordinate.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/ScreenCoordinate.swift @@ -5,20 +5,20 @@ import MapboxCoreMaps // MARK: - ScreenCoordinate -public extension ScreenCoordinate { +extension ScreenCoordinate { // swiftlint:disable identifier_name /// Initializes an internal `ScreenCoordinate` type from two `CGFloat` values. /// - Parameters: /// - x: The horizontal point along the screen's coordinate system. /// - y: The vertical point along the screen's coordinate system. - convenience init(x: CGFloat, y: CGFloat) { + internal convenience init(x: CGFloat, y: CGFloat) { self.init(x: Double(x), y: Double(y)) } // swiftlint:enable identifier_name /// Returns a `CGPoint` representation of an internal `ScreenCoordinate` value. - var point: CGPoint { + internal var point: CGPoint { CGPoint(x: x, y: y) } } diff --git a/Sources/MapboxMaps/Foundation/Extensions/CoreGraphics.swift b/Sources/MapboxMaps/Foundation/Extensions/CoreGraphics.swift index 5d067d79222..0ba9d7b3669 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/CoreGraphics.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/CoreGraphics.swift @@ -4,10 +4,10 @@ import CoreGraphics import MapboxCoreMaps // MARK: - CGPoint -public extension CGPoint { +extension CGPoint { /// Converts a `CGPoint` to an internal `ScreenCoordinate` type. - var screenCoordinate: ScreenCoordinate { + internal var screenCoordinate: ScreenCoordinate { ScreenCoordinate(x: Double(x), y: Double(y)) } @@ -20,17 +20,17 @@ public extension CGPoint { /// represents the end position. /// - Returns: A `CGPoint` that represents the fractional point along the path /// between the source and destination points. - static func interpolate(origin: CGPoint, destination: CGPoint, fraction: CGFloat) -> CGPoint { + internal static func interpolate(origin: CGPoint, destination: CGPoint, fraction: CGFloat) -> CGPoint { return CGPoint(x: origin.x + fraction * (destination.x - origin.x), y: origin.y + fraction * (destination.y - origin.y)) } } // MARK: - CGFloat -public extension CGFloat { +extension CGFloat { /// Converts a `CGFloat` to a `NSValue` which wraps a `Double`. - var NSNumber: NSNumber { + internal var NSNumber: NSNumber { Foundation.NSNumber(value: Double(self)) } } @@ -41,7 +41,7 @@ extension CGRect { /// Returns a new `CGRect` whose origin is a given `CGPoint` value. /// - Parameter originPoint: The `CGPoint` which acts as the origin of the new `CGRect`. /// - Note: This method is the equivalent of `MGLExtendRect` in pre-v10.0.0 versions of the SDK. - func extend(from originPoint: CGPoint) -> CGRect { + internal func extend(from originPoint: CGPoint) -> CGRect { var rect = self diff --git a/Sources/MapboxMaps/Foundation/Extensions/CoreLocation.swift b/Sources/MapboxMaps/Foundation/Extensions/CoreLocation.swift index 3cd5d25ad69..836aa9f970e 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/CoreLocation.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/CoreLocation.swift @@ -4,15 +4,15 @@ import CoreGraphics import MapboxCoreMaps // MARK: - CLLocationCoordinate2D -public extension CLLocationCoordinate2D { +extension CLLocationCoordinate2D { /// Converts a `CLLocationCoordinate` to a `CLLocation`. - var location: CLLocation { + internal var location: CLLocation { CLLocation(latitude: latitude, longitude: longitude) } /// Returns a new `CLLocationCoordinate` value with a new longitude constrained to [-180, +180] degrees. - func wrap() -> CLLocationCoordinate2D { + internal func wrap() -> CLLocationCoordinate2D { /** mbgl::geo.hpp equivalent: @@ -30,7 +30,7 @@ public extension CLLocationCoordinate2D { /// the distance from start to end longitudes is between a half and full /// world, ensuring that the shortest path is taken. /// - Parameter end: The coordinate to possibly wrap, if needed. - func unwrapForShortestPath(_ end: CLLocationCoordinate2D) -> CLLocationCoordinate2D { + internal func unwrapForShortestPath(_ end: CLLocationCoordinate2D) -> CLLocationCoordinate2D { let delta = fabs(end.longitude - longitude) if delta <= 180.0 || delta >= 360 { @@ -62,10 +62,10 @@ public extension CLLocationCoordinate2D { } // MARK: - CLLocationDirection -public extension CLLocationDirection { +extension CLLocationDirection { /// Converts a `CLLocationDirection` to an `NSNumber` containing a `Double`. - var NSNumber: NSNumber { + internal var NSNumber: NSNumber { Foundation.NSNumber(value: Double(self)) } } diff --git a/Sources/MapboxMaps/Foundation/Extensions/Int.swift b/Sources/MapboxMaps/Foundation/Extensions/Int.swift index 658d43d1fff..43a66dc58a7 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Int.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Int.swift @@ -1,10 +1,10 @@ import Foundation // MARK: - Int -public extension Int { +extension Int { /// Wraps an `Int` within a `NSNumber` value. - var NSNumber: NSNumber { + internal var NSNumber: NSNumber { Foundation.NSNumber(value: Int(self)) } } diff --git a/Sources/MapboxMaps/Foundation/Extensions/UIImage.swift b/Sources/MapboxMaps/Foundation/Extensions/UIImage.swift index 5073d77468c..5f53de75e39 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/UIImage.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/UIImage.swift @@ -2,13 +2,13 @@ import UIKit // MARK: - UIImage -public extension UIImage { +extension UIImage { /// Initialize a `UIImage` with an internal `Image` type, using a givens scale. /// - Parameters: /// - mbxImage: The internal `Image` type to use for the `UIImage`. /// - scale: The scale of the new `UIImage`. - convenience init?(mbxImage: Image, scale: CGFloat = UIScreen.main.scale) { + internal convenience init?(mbxImage: Image, scale: CGFloat = UIScreen.main.scale) { let cgImage = mbxImage.cgImage().takeUnretainedValue() let size = CGSize(width: CGFloat(CGFloat(mbxImage.width) / scale), diff --git a/Sources/MapboxMaps/Foundation/MapboxLogoView.swift b/Sources/MapboxMaps/Foundation/LogoView.swift similarity index 99% rename from Sources/MapboxMaps/Foundation/MapboxLogoView.swift rename to Sources/MapboxMaps/Foundation/LogoView.swift index 53815d1a1bf..da2711df320 100644 --- a/Sources/MapboxMaps/Foundation/MapboxLogoView.swift +++ b/Sources/MapboxMaps/Foundation/LogoView.swift @@ -1,9 +1,9 @@ import UIKit // swiftlint:disable function_body_length file_length type_body_length -public class MapboxLogoView: UIView { +public class LogoView: UIView { - public enum MapboxLogoSize: RawRepresentable { + public enum LogoSize: RawRepresentable { case regular case compact @@ -27,9 +27,9 @@ public class MapboxLogoView: UIView { } } - internal var logoSize: MapboxLogoSize + internal var logoSize: LogoSize - public init(logoSize: MapboxLogoSize) { + public init(logoSize: LogoSize) { let frame = CGRect(origin: .zero, size: logoSize.rawValue) self.logoSize = logoSize super.init(frame: frame) diff --git a/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift b/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift index c662736cf89..41ed4cca805 100644 --- a/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift +++ b/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift @@ -59,11 +59,11 @@ extension GestureManager: GestureHandlerDelegate { } internal func cancelGestureTransitions() { - cameraManager.cancelTransitions() + cameraManager.cancelAnimations() } internal func gestureBegan(for gestureType: GestureType) { - cameraManager.cancelTransitions() + cameraManager.cancelAnimations() delegate?.gestureBegan(for: gestureType) } diff --git a/Sources/MapboxMaps/Gestures/GestureManager.swift b/Sources/MapboxMaps/Gestures/GestureManager.swift index 87e04e2059b..71359e73c79 100644 --- a/Sources/MapboxMaps/Gestures/GestureManager.swift +++ b/Sources/MapboxMaps/Gestures/GestureManager.swift @@ -5,7 +5,7 @@ import CoreLocation import MapboxMapsFoundation #endif -public enum GestureType: Hashable { +internal enum GestureType: Hashable { /// The pan gesture type case pan @@ -100,7 +100,7 @@ internal class GestureHandler { } } -public protocol GestureManagerDelegate: AnyObject { +internal protocol GestureManagerDelegate: AnyObject { /// Informs the delegate that a gesture haas begun. Could be used to cancel camera tracking. func gestureBegan(for gestureType: GestureType) @@ -117,7 +117,7 @@ internal protocol CameraManagerProtocol: AnyObject { duration: TimeInterval, completion: ((UIViewAnimatingPosition) -> Void)?) - func cancelTransitions() + func cancelAnimations() } extension CameraManager: CameraManagerProtocol { } @@ -136,7 +136,7 @@ public final class GestureManager: NSObject { /// The camera manager that responds to gestures. internal let cameraManager: CameraManagerProtocol - public weak var delegate: GestureManagerDelegate? + internal weak var delegate: GestureManagerDelegate? internal init(for view: UIView, options: GestureOptions, cameraManager: CameraManagerProtocol) { self.cameraManager = cameraManager diff --git a/Sources/MapboxMaps/MapView/Configuration/LayoutPosition.swift b/Sources/MapboxMaps/MapView/Configuration/LayoutPosition.swift deleted file mode 100644 index af1bf81245f..00000000000 --- a/Sources/MapboxMaps/MapView/Configuration/LayoutPosition.swift +++ /dev/null @@ -1,36 +0,0 @@ -import Foundation - -/// Enum that provides options for positioning an ornament -public enum LayoutPosition: String, Equatable { - case topLeft - case topCenter - case topRight - case centerRight - case bottomRight - case bottomCenter - case bottomLeft - case centerLeft -} - -extension LayoutPosition { - internal var ornamentPosition: OrnamentPosition { - switch self { - case .topLeft: - return .topLeft - case .topCenter: - return .topCenter - case .topRight: - return .topRight - case .centerRight: - return .centerRight - case .bottomRight: - return .bottomRight - case .bottomCenter: - return .bottomCenter - case .bottomLeft: - return .bottomLeft - case .centerLeft: - return .centerLeft - } - } -} diff --git a/Sources/MapboxMaps/MapView/Configuration/LayoutVisibility.swift b/Sources/MapboxMaps/MapView/Configuration/LayoutVisibility.swift deleted file mode 100644 index d8cadd2c2d6..00000000000 --- a/Sources/MapboxMaps/MapView/Configuration/LayoutVisibility.swift +++ /dev/null @@ -1,26 +0,0 @@ -import Foundation - -/// Constants indicating the visibility of different map ornaments. -public enum LayoutVisibility: String, Equatable { - /// A constant indicating that the ornament adapts to the current map state. - case adaptive - - /// A constant indicating that the ornament is always hidden. - case hidden - - /// A constant indicating that the ornament is always visible. - case visible -} - -extension LayoutVisibility { - internal var ornamentVisibility: OrnamentVisibility { - switch self { - case .adaptive: - return .adaptive - case .hidden: - return .hidden - case .visible: - return .visible - } - } -} diff --git a/Sources/MapboxMaps/MapView/Configuration/OrnamentOptions.swift b/Sources/MapboxMaps/MapView/Configuration/OrnamentOptions.swift index 5fcad794d31..661c910eff8 100644 --- a/Sources/MapboxMaps/MapView/Configuration/OrnamentOptions.swift +++ b/Sources/MapboxMaps/MapView/Configuration/OrnamentOptions.swift @@ -6,24 +6,23 @@ private let defaultOrnamentsMargin = CGPoint(x: 8.0, y: 8.0) public struct OrnamentOptions: Equatable { /// Scale Bar options - public var showsScale: Bool = true - public var scaleBarPosition: LayoutPosition = .topLeft + public var scaleBarPosition: OrnamentPosition = .topLeft public var scaleBarMargins: CGPoint = defaultOrnamentsMargin + public var scaleBarVisibility: OrnamentVisibility = .adaptive /// Compass options - public var showsCompass: Bool = true - public var compassViewPosition: LayoutPosition = .topRight + public var compassViewPosition: OrnamentPosition = .topRight public var compassViewMargins: CGPoint = defaultOrnamentsMargin - public var compassVisiblity: LayoutVisibility = .adaptive + public var compassVisiblity: OrnamentVisibility = .adaptive /// Logo view options - public private(set) var showsLogoView: Bool = true - public var logoViewPosition: LayoutPosition = .bottomLeft + public var _showsLogoView: Bool = true + public var logoViewPosition: OrnamentPosition = .bottomLeft public var logoViewMargins: CGPoint = defaultOrnamentsMargin /// Attribution options - public private(set) var showsAttributionButton: Bool = true - public var attributionButtonPosition: LayoutPosition = .bottomRight + public var _showsAttributionButton: Bool = true + public var attributionButtonPosition: OrnamentPosition = .bottomRight public var attributionButtonMargins: CGPoint = defaultOrnamentsMargin /// Used to generate the internal `OrnamentConfig` used by the `OrnamentsManager` to configure the map. @@ -33,24 +32,24 @@ public struct OrnamentOptions: Equatable { var supportedOrnamentMargins: [OrnamentType: OrnamentMargins] = [:] var ornamentVisibility: [OrnamentType: OrnamentVisibility] = [:] - if showsScale { - supportedOrnaments[.mapboxScaleBar] = scaleBarPosition.ornamentPosition + if scaleBarVisibility != .hidden { + supportedOrnaments[.mapboxScaleBar] = scaleBarPosition supportedOrnamentMargins[.mapboxScaleBar] = scaleBarMargins } - if showsCompass { - supportedOrnaments[.compass] = compassViewPosition.ornamentPosition + if compassVisiblity != .hidden { + supportedOrnaments[.compass] = compassViewPosition supportedOrnamentMargins[.compass] = compassViewMargins - ornamentVisibility[.compass] = compassVisiblity.ornamentVisibility + ornamentVisibility[.compass] = compassVisiblity } - if showsLogoView { - supportedOrnaments[.mapboxLogoView] = logoViewPosition.ornamentPosition + if _showsLogoView { + supportedOrnaments[.mapboxLogoView] = logoViewPosition supportedOrnamentMargins[.mapboxLogoView] = logoViewMargins } - if showsAttributionButton { - supportedOrnaments[.infoButton] = attributionButtonPosition.ornamentPosition + if _showsAttributionButton { + supportedOrnaments[.infoButton] = attributionButtonPosition supportedOrnamentMargins[.infoButton] = attributionButtonMargins } diff --git a/Sources/MapboxMaps/MapView/MapView+Supportable.swift b/Sources/MapboxMaps/MapView/MapView+Supportable.swift index 0f7d8feda3c..2bbb31eed35 100644 --- a/Sources/MapboxMaps/MapView/MapView+Supportable.swift +++ b/Sources/MapboxMaps/MapView/MapView+Supportable.swift @@ -3,11 +3,11 @@ import CoreLocation extension MapView: OrnamentSupportableView { // User has tapped on an ornament - public func tapped() { + internal func tapped() { } - public func compassTapped() { + internal func compassTapped() { // Don't have access to CameraManager, so calling UIView.animate directly. UIView.animate(withDuration: 0.3, delay: 0.0, @@ -17,7 +17,7 @@ extension MapView: OrnamentSupportableView { }, completion: nil) } - public func subscribeCameraChangeHandler(_ handler: @escaping (CameraOptions) -> Void) { + internal func subscribeCameraChangeHandler(_ handler: @escaping (CameraOptions) -> Void) { on(.cameraChanged) { [weak self] _ in guard let validSelf = self else { return } handler(try! validSelf.__map.getCameraOptions(forPadding: nil)) diff --git a/Sources/MapboxMaps/MapView/MapView.swift b/Sources/MapboxMaps/MapView/MapView.swift index 2c2f5e15e7a..f220c939ce8 100644 --- a/Sources/MapboxMaps/MapView/MapView.swift +++ b/Sources/MapboxMaps/MapView/MapView.swift @@ -1,7 +1,7 @@ import Foundation import Turf -open class MapView: BaseMapView, EventsEmitter { +open class MapView: BaseMapView { /// The `mapOptions` structure is the interface for consumers to configure the map. /// It's initialized on the creation of the `MapView` with a set of sane, default values. @@ -27,10 +27,10 @@ open class MapView: BaseMapView, EventsEmitter { public internal(set) var annotationManager: AnnotationManager! /// A reference to the `EventsManager` used for dispatching telemetry. - public var eventsListener: EventsListener! + internal var eventsListener: EventsListener! - public init(with frame: CGRect, resourceOptions: ResourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions.default, styleURI: StyleURI? = .streets) { - super.init(with: frame, resourceOptions: resourceOptions, glyphsRasterizationOptions: glyphsRasterizationOptions, styleURI: styleURI?.url) + public init(frame: CGRect, resourceOptions: ResourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions.default, styleURI: StyleURI? = .streets) { + super.init(frame: frame, resourceOptions: resourceOptions, glyphsRasterizationOptions: glyphsRasterizationOptions, styleURI: styleURI?.rawValue) initialize() } diff --git a/Sources/MapboxMaps/Ornaments/Compass/CompassDirectionFormatter.swift b/Sources/MapboxMaps/Ornaments/Compass/CompassDirectionFormatter.swift index 9f9606e52f2..8a480e49cf0 100644 --- a/Sources/MapboxMaps/Ornaments/Compass/CompassDirectionFormatter.swift +++ b/Sources/MapboxMaps/Ornaments/Compass/CompassDirectionFormatter.swift @@ -336,11 +336,11 @@ private enum Constants { }() } -public class CompassDirectionFormatter { +internal class CompassDirectionFormatter { private static let longStrings: [String] = [] - public var unitStyle: Formatter.UnitStyle = .medium + internal var unitStyle: Formatter.UnitStyle = .medium - public func string(from direction: CLLocationDirection) -> String { + internal func string(from direction: CLLocationDirection) -> String { assert(Constants.shortStrings.count == Constants.longStrings.count, "The numbers of short and long strings should be the same") let stringsCount = Constants.shortStrings.count diff --git a/Sources/MapboxMaps/Ornaments/Compass/MapboxCompassOrnamentView.swift b/Sources/MapboxMaps/Ornaments/Compass/MapboxCompassOrnamentView.swift index 57011a6df9d..2a22ba96a5b 100644 --- a/Sources/MapboxMaps/Ornaments/Compass/MapboxCompassOrnamentView.swift +++ b/Sources/MapboxMaps/Ornaments/Compass/MapboxCompassOrnamentView.swift @@ -5,7 +5,7 @@ import UIKit import MapboxMapsFoundation #endif -public class MapboxCompassOrnamentView: UIButton { +internal class MapboxCompassOrnamentView: UIButton { private enum Constants { static let localizableTableName = "OrnamentsLocalizable" static let compassSize = CGSize(width: 40, height: 40) @@ -25,7 +25,7 @@ public class MapboxCompassOrnamentView: UIButton { private var lineColor: UIColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) private let directionFormatter = CompassDirectionFormatter() /// Should be in range [-pi; pi] - public var currentBearing: CLLocationDirection = 0 { + internal var currentBearing: CLLocationDirection = 0 { didSet { let adjustedBearing = currentBearing.truncatingRemainder(dividingBy: 360) updateVisibility() @@ -33,7 +33,7 @@ public class MapboxCompassOrnamentView: UIButton { } } - required public init(visibility: OrnamentVisibility) { + required internal init(visibility: OrnamentVisibility) { super.init(frame: .zero) translatesAutoresizingMaskIntoConstraints = false self.visibility = visibility diff --git a/Sources/MapboxMaps/Ornaments/OrnamentConfig.swift b/Sources/MapboxMaps/Ornaments/OrnamentConfig.swift index 127dc73ecd3..3dd429d2b2a 100644 --- a/Sources/MapboxMaps/Ornaments/OrnamentConfig.swift +++ b/Sources/MapboxMaps/Ornaments/OrnamentConfig.swift @@ -1,13 +1,13 @@ import UIKit -public typealias OrnamentMargins = CGPoint +internal typealias OrnamentMargins = CGPoint -public class Ornament: Equatable { - public var view: UIView? - public let type: OrnamentType - public let position: OrnamentPosition - public let margins: OrnamentMargins - public let visibility: OrnamentVisibility +internal class Ornament: Equatable { + internal var view: UIView? + internal let type: OrnamentType + internal let position: OrnamentPosition + internal let margins: OrnamentMargins + internal let visibility: OrnamentVisibility convenience internal init(view: UIView?, type: OrnamentType, @@ -16,11 +16,11 @@ public class Ornament: Equatable { self.init(view: view, type: type, position: position, margins: .defaultMargins, visibility: visibility) } - public init(view: UIView?, - type: OrnamentType, - position: OrnamentPosition, - margins: OrnamentMargins, - visibility: OrnamentVisibility) { + internal init(view: UIView?, + type: OrnamentType, + position: OrnamentPosition, + margins: OrnamentMargins, + visibility: OrnamentVisibility) { self.view = view self.type = type self.position = position @@ -28,12 +28,12 @@ public class Ornament: Equatable { self.visibility = visibility } - public static func == (lhs: Ornament, rhs: Ornament) -> Bool { + internal static func == (lhs: Ornament, rhs: Ornament) -> Bool { return lhs.type == rhs.type && lhs.position == rhs.position && lhs.margins == rhs.margins } } -public struct OrnamentConfig: Equatable { +internal struct OrnamentConfig: Equatable { internal let ornaments: [Ornament] /** diff --git a/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift b/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift index 6885da1331b..13bd7f9113f 100644 --- a/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift +++ b/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift @@ -50,7 +50,7 @@ public enum OrnamentType: Hashable { internal func makeOrnament(for view: OrnamentSupportableView, visibility: OrnamentVisibility = .visible) -> UIView { switch self { case .mapboxLogoView: - return MapboxLogoView(logoSize: .regular) + return LogoView(logoSize: .regular) case .mapboxScaleBar: let scalebarView = MapboxScaleBarOrnamentView() @@ -246,7 +246,7 @@ internal class OrnamentsManager: NSObject { also make the watermark seem disproportionally large on an iPad. Consider using size classes to figure out height/width instead. */ - if ornamentView is MapboxLogoView { + if ornamentView is LogoView { constraints.append(contentsOf: [ ornamentView.widthAnchor.constraint(equalTo: universalLayoutGuide.widthAnchor, multiplier: 0.25), ornamentView.heightAnchor.constraint(equalTo: ornamentView.widthAnchor, multiplier: 0.25) diff --git a/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarLabel.swift b/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarLabel.swift index bc512f6c68f..7d789b4a86b 100644 --- a/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarLabel.swift +++ b/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarLabel.swift @@ -1,8 +1,8 @@ import UIKit -public class MapboxScaleBarLabel: UILabel { +internal class MapboxScaleBarLabel: UILabel { - override public func drawText(in rect: CGRect) { + override internal func drawText(in rect: CGRect) { let originalShadowOffset = shadowOffset let context = UIGraphicsGetCurrentContext() diff --git a/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarOrnamentView.swift b/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarOrnamentView.swift index 9e31e89bf03..70d9aa9e1d2 100644 --- a/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarOrnamentView.swift +++ b/Sources/MapboxMaps/Ornaments/ScaleBar/MapboxScaleBarOrnamentView.swift @@ -5,13 +5,13 @@ import CoreLocation import MapboxMapsFoundation #endif -public class MapboxScaleBarOrnamentView: UIView { +internal class MapboxScaleBarOrnamentView: UIView { - public typealias Row = (distance: CLLocationDistance, numberOfBars: UInt) + internal typealias Row = (distance: CLLocationDistance, numberOfBars: UInt) // MARK: - Properties - public var metersPerPoint: CLLocationDistance = 1 { + internal var metersPerPoint: CLLocationDistance = 1 { didSet { guard metersPerPoint != oldValue else { return @@ -105,7 +105,7 @@ public class MapboxScaleBarOrnamentView: UIView { return Locale(identifier: Bundle.main.preferredLocalizations.first!).usesMetricSystem } - public override var intrinsicContentSize: CGSize { + internal override var intrinsicContentSize: CGSize { // Size is calculated elsewhere - since 'intrinsicContentSize' is part of the // constraint system, this should be done in 'updateConstraints' guard size.width >= 0 else { @@ -116,7 +116,7 @@ public class MapboxScaleBarOrnamentView: UIView { // MARK: - Initialization - override public init(frame: CGRect) { + override internal init(frame: CGRect) { super.init(frame: frame) commonInit() } @@ -149,7 +149,7 @@ public class MapboxScaleBarOrnamentView: UIView { // current 'row', which in turn determines the "actualWidth". To obtain the full // width of the scale bar, we also need to include some space for the "last" // label - public override func updateConstraints() { + internal override func updateConstraints() { guard !isHidden && needsRecalculateSize else { super.updateConstraints() return @@ -185,7 +185,7 @@ public class MapboxScaleBarOrnamentView: UIView { super.updateConstraints() // This calls intrinsicContentSize } - public override func layoutSubviews() { + internal override func layoutSubviews() { super.layoutSubviews() guard needsRecalculateSize else { diff --git a/Sources/MapboxMaps/Ornaments/ScaleBar/MapbxoScaleBarConstants.swift b/Sources/MapboxMaps/Ornaments/ScaleBar/MapbxoScaleBarConstants.swift index 90b845cd8e1..4ded484c058 100644 --- a/Sources/MapboxMaps/Ornaments/ScaleBar/MapbxoScaleBarConstants.swift +++ b/Sources/MapboxMaps/Ornaments/ScaleBar/MapbxoScaleBarConstants.swift @@ -3,18 +3,18 @@ import UIKit extension MapboxScaleBarOrnamentView { struct Constants { - public static let primaryColor: UIColor = #colorLiteral(red: 0.07058823529, green: 0.1764705882, blue: 0.06666666667, alpha: 1) - public static let secondaryColor: UIColor = #colorLiteral(red: 0.968627451, green: 0.968627451, blue: 0.968627451, alpha: 1) - public static let borderWidth: CGFloat = 1 + internal static let primaryColor: UIColor = #colorLiteral(red: 0.07058823529, green: 0.1764705882, blue: 0.06666666667, alpha: 1) + internal static let secondaryColor: UIColor = #colorLiteral(red: 0.968627451, green: 0.968627451, blue: 0.968627451, alpha: 1) + internal static let borderWidth: CGFloat = 1 - public static let feetPerMile: Double = 5280 - public static let feetPerMeter: Double = 3.28084 + internal static let feetPerMile: Double = 5280 + internal static let feetPerMeter: Double = 3.28084 - public static let barHeight: CGFloat = 4 - public static let scaleBarLabelWidthHint: CGFloat = 30.0 - public static let scaleBarMinimumBarWidth: CGFloat = 30.0 // Arbitrary + internal static let barHeight: CGFloat = 4 + internal static let scaleBarLabelWidthHint: CGFloat = 30.0 + internal static let scaleBarMinimumBarWidth: CGFloat = 30.0 // Arbitrary - public static let metricTable: [Row] = [ + internal static let metricTable: [Row] = [ (distance: 1, numberOfBars: 2), (distance: 2, numberOfBars: 2), (distance: 4, numberOfBars: 2), @@ -44,7 +44,7 @@ extension MapboxScaleBarOrnamentView { (distance: 800000, numberOfBars: 2) ] - public static let imperialTable: [Row] = [ + internal static let imperialTable: [Row] = [ (distance: 4, numberOfBars: 2), (distance: 6, numberOfBars: 2), (distance: 10, numberOfBars: 2), diff --git a/Sources/MapboxMaps/MapView/Configuration/MapSnapshotOptions.swift b/Sources/MapboxMaps/Snapshot/MapSnapshotOptions.swift similarity index 100% rename from Sources/MapboxMaps/MapView/Configuration/MapSnapshotOptions.swift rename to Sources/MapboxMaps/Snapshot/MapSnapshotOptions.swift diff --git a/Sources/MapboxMaps/Snapshot/Snapshotter.swift b/Sources/MapboxMaps/Snapshot/Snapshotter.swift index 586f9d6e93f..4b4b5a1077f 100644 --- a/Sources/MapboxMaps/Snapshot/Snapshotter.swift +++ b/Sources/MapboxMaps/Snapshot/Snapshotter.swift @@ -30,7 +30,7 @@ public class Snapshotter: Observer { } /// A `style` object that can be manipulated to set different styles for a snapshot - public private(set) var style: Style + public let style: Style /// Initialize a `Snapshotter` instance /// - Parameters: @@ -151,7 +151,7 @@ public class Snapshotter: Observer { // Composite the logo on the snapshot, // only after everything else has been drawn. - let logoView = MapboxLogoView(logoSize: .regular) + let logoView = LogoView(logoSize: .regular) let logoPadding = CGFloat(10.0) let logoOrigin = CGPoint(x: logoPadding, y: uiImage.size.height - logoView.frame.size.height - logoPadding) @@ -189,7 +189,7 @@ public class Snapshotter: Observer { internal func compositeLogo(for snapshotImage: UIImage) -> UIImage { let rect = CGRect(origin: .zero, size: snapshotImage.size) - let logoView = MapboxLogoView(logoSize: .regular) + let logoView = LogoView(logoSize: .regular) let renderer = UIGraphicsImageRenderer(size: snapshotImage.size) diff --git a/Sources/MapboxMaps/Style/Generated/Layers/FillLayer.swift b/Sources/MapboxMaps/Style/Generated/Layers/FillLayer.swift index 581b3243f82..ca0a74bbd15 100644 --- a/Sources/MapboxMaps/Style/Generated/Layers/FillLayer.swift +++ b/Sources/MapboxMaps/Style/Generated/Layers/FillLayer.swift @@ -124,4 +124,4 @@ public struct FillLayer: Layer { } } -// End of generated file. \ No newline at end of file +// End of generated file. diff --git a/Sources/MapboxMaps/Style/Layers.swift b/Sources/MapboxMaps/Style/Layers.swift index 85436e48791..f735813b854 100644 --- a/Sources/MapboxMaps/Style/Layers.swift +++ b/Sources/MapboxMaps/Style/Layers.swift @@ -4,38 +4,38 @@ import MapboxCoreMaps /// Layer rendering types public enum LayerType: String, Codable { /// A filled polygon with an optional stroked border. - case fill = "fill" + case fill /// A stroked line. - case line = "line" + case line /// An icon or a text label. - case symbol = "symbol" + case symbol /// A filled circle. - case circle = "circle" + case circle /// A heatmap. - case heatmap = "heatmap" + case heatmap /// An extruded (3D) polygon. case fillExtrusion = "fill-extrusion" /// Raster map textures such as satellite imagery. - case raster = "raster" + case raster /// Client-side hillshading visualization based on DEM data. /// Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles. - case hillshade = "hillshade" + case hillshade /// The background color or pattern of the map. - case background = "background" + case background /// Layer representing the location indicator case locationIndicator = "location-indicator" /// Layer representing the sky - case sky = "sky" + case sky /// Layer used for a 3D model case model = "model" @@ -106,9 +106,3 @@ public extension Layer { self = try JSONDecoder().decode(Self.self, from: layerData) } } - -public extension LayerPosition { - convenience init(above: String? = nil, below: String? = nil, at: Int? = nil) { - self.init(__above: above, below: below, at: at?.NSNumber) - } -} diff --git a/Sources/MapboxMaps/Style/Style.swift b/Sources/MapboxMaps/Style/Style.swift index 9f2cf4521e6..ba6d2ce043a 100644 --- a/Sources/MapboxMaps/Style/Style.swift +++ b/Sources/MapboxMaps/Style/Style.swift @@ -7,7 +7,7 @@ import MapboxMapsFoundation public class Style { public private(set) weak var styleManager: StyleManager! - public init(with styleManager: StyleManager) { + internal init(with styleManager: StyleManager) { self.styleManager = styleManager } @@ -23,9 +23,9 @@ public class Style { receiver will use the default style and this property will automatically be set to that style’s URL. */ - public var styleURI: StyleURI = .streets { + public var uri: StyleURI = .streets { didSet { - let uriString = styleURI.url.absoluteString + let uriString = uri.rawValue.absoluteString try! styleManager.setStyleURIForUri(uriString) } } diff --git a/Sources/MapboxMaps/Style/StyleURI.swift b/Sources/MapboxMaps/Style/StyleURI.swift index 9e2bcdc6f79..ea586fcfc8c 100644 --- a/Sources/MapboxMaps/Style/StyleURI.swift +++ b/Sources/MapboxMaps/Style/StyleURI.swift @@ -29,11 +29,6 @@ public enum StyleURI: Hashable, RawRepresentable { /// resource path. case custom(url: URL) - /// Underlying URL for the StyleURI - public var url: URL { - return rawValue - } - /// :nodoc: /// `RawRepresentable` conformance public var rawValue: URL { diff --git a/Sources/MapboxMaps/Style/Types/Color.swift b/Sources/MapboxMaps/Style/Types/Color.swift index 0f3b9737fc1..c27802995c2 100644 --- a/Sources/MapboxMaps/Style/Types/Color.swift +++ b/Sources/MapboxMaps/Style/Types/Color.swift @@ -4,12 +4,12 @@ import UIKit public struct ColorRepresentable: Codable, Equatable { /// Expression representation of a `UIColor` used by the renderer - public let colorRepresentation: Expression? + internal let colorRepresentation: Expression? /// `UIColor` instance represented by this `ColorRepresentable` - public var uiColor: UIColor? { + internal var uiColor: UIColor? { - if case let .op(rgbaOp) = colorRepresentation?.elements[0], + if case let .operator(rgbaOp) = colorRepresentation?.elements[0], rgbaOp == .rgba, // operator must be `rgba` case let .argument(.number(red)) = colorRepresentation?.elements[1], // red case let .argument(.number(green)) = colorRepresentation?.elements[2], // green @@ -75,7 +75,7 @@ public struct ColorRepresentable: Codable, Equatable { } } -extension UIColor: ValidExpressionArgument { +extension UIColor: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { var red: CGFloat = 0.0 diff --git a/Sources/MapboxMaps/Style/Types/Expression.swift b/Sources/MapboxMaps/Style/Types/Expression.swift index 6df917d2a10..d29b1c64728 100644 --- a/Sources/MapboxMaps/Style/Types/Expression.swift +++ b/Sources/MapboxMaps/Style/Types/Expression.swift @@ -5,7 +5,7 @@ public typealias Exp = Expression public struct Expression: Codable, CustomStringConvertible, Equatable { /// The individual elements of the expression in an array - public var elements: [Element] + internal var elements: [Element] // swiftlint:disable identifier_name public init(_ op: Expression.Operator, @@ -16,28 +16,10 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { elements = [] } - elements.insert(.op(op), at: 0) + elements.insert(.operator(op), at: 0) self.init(with: elements) } - /// Attempts to create an Expression from a jsonObject. - public init?(from jsonObject: Any) { - do { - let data = try JSONSerialization.data(withJSONObject: jsonObject, options: []) - let exp = try JSONDecoder().decode(Expression.self, from: data) - self = exp - } catch { - return nil - } - } - - /// Returns a jsonObject representation of this expression if serialization is successful, throws otherwise - public func jsonObject() throws -> Any { - let data = try JSONEncoder().encode(self) - let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) - return jsonObject - } - public func encode(to encoder: Encoder) throws { var container = encoder.unkeyedContainer() @@ -69,12 +51,12 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { */ public indirect enum Element: Codable, CustomStringConvertible, Equatable { - case op(Operator) + case `operator`(Operator) case argument(Argument) public var description: String { switch self { - case .op(let op): + case .operator(let op): return op.rawValue case .argument(let arg): return "\(arg)" @@ -83,7 +65,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { public static func == (lhs: Expression.Element, rhs: Expression.Element) -> Bool { switch (lhs, rhs) { - case (.op(let lhsOp), .op(let rhsOp)): + case (.operator(let lhsOp), .operator(let rhsOp)): return lhsOp.rawValue == rhsOp.rawValue case (.argument(let lhsArg), .argument(let rhsArg)): return lhsArg == rhsArg @@ -96,7 +78,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { var container = encoder.singleValueContainer() switch self { - case .op(let op): + case .operator(let op): try container.encode(op) case .argument(let argument): try container.encode(argument) @@ -107,7 +89,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { let container = try decoder.singleValueContainer() if let validOp = try? container.decode(Operator.self) { - self = .op(validOp) + self = .operator(validOp) return } @@ -129,7 +111,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { case number(Double) case string(String) case boolean(Bool) - case array([Double]) + case numberArray([Double]) case option(Option) case null case expression(Expression) @@ -148,7 +130,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { return "\(exp)" case .option(let option): return "\(option)" - case .array(let array): + case .numberArray(let array): return "\(array)" } } @@ -167,7 +149,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { return true case (.expression(let lhsExpression), .expression(let rhsExpression)): return lhsExpression == rhsExpression - case (.array(let lhsArray), .array(let rhsArray)): + case (.numberArray(let lhsArray), .numberArray(let rhsArray)): return lhsArray == rhsArray default: return false @@ -190,7 +172,7 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { try container.encode(option) case .null: try container.encodeNil() - case .array(let array): + case .numberArray(let array): try container.encode(array) } } @@ -210,12 +192,12 @@ public struct Expression: Codable, CustomStringConvertible, Equatable { } else if let validOption = try? container.decode(Option.self) { self = .option(validOption) } else if let validArray = try? container.decode([Double].self) { - self = .array(validArray) + self = .numberArray(validArray) } else if let dict = try? container.decode([String: String].self), dict.isEmpty { self = .null } else { let context = DecodingError.Context(codingPath: decoder.codingPath, - debugDescription: "Failed to decode ExpressionArgument") + debugDescription: "Failed to decode ExpressionArgument") throw DecodingError.dataCorrupted(context) } } diff --git a/Sources/MapboxMaps/Style/Types/ExpressionBuilder.swift b/Sources/MapboxMaps/Style/Types/ExpressionBuilder.swift index 1fd17b91936..5e786aa598c 100644 --- a/Sources/MapboxMaps/Style/Types/ExpressionBuilder.swift +++ b/Sources/MapboxMaps/Style/Types/ExpressionBuilder.swift @@ -4,7 +4,7 @@ import UIKit @_functionBuilder public struct ExpressionBuilder { - public static func buildBlock(_ arguments: ValidExpressionArgument...) -> Expression { + public static func buildBlock(_ arguments: ExpressionArgumentConvertible...) -> Expression { var expressionElements = [Expression.Element]() @@ -16,72 +16,72 @@ public struct ExpressionBuilder { } } -public protocol ValidExpressionArgument { +public protocol ExpressionArgumentConvertible { var expressionElements: [Expression.Element] { get } } -extension Int: ValidExpressionArgument { +extension Int: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.number(Double(self)))] } } -extension UInt: ValidExpressionArgument { +extension UInt: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.number(Double(self)))] } } -extension Double: ValidExpressionArgument { +extension Double: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.number(Double(self)))] } } -extension String: ValidExpressionArgument { +extension String: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.string(self))] } } -extension Bool: ValidExpressionArgument { +extension Bool: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.boolean(self))] } } -extension Array: ValidExpressionArgument where Element == Double { +extension Array: ExpressionArgumentConvertible where Element == Double { public var expressionElements: [Expression.Element] { - return [.argument(.array(self))] + return [.argument(.numberArray(self))] } } -extension Expression.Element: ValidExpressionArgument { +extension Expression.Element: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [self] } } -extension Expression: ValidExpressionArgument { +extension Expression: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(.expression(self))] } } -extension Expression.Argument: ValidExpressionArgument { +extension Expression.Argument: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { return [.argument(self)] } } -extension Expression.Operator: ValidExpressionArgument { +extension Expression.Operator: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { - return [.op(self)] + return [.operator(self)] } } -extension Dictionary: ValidExpressionArgument where Key == Double, - Value: ValidExpressionArgument { +extension Dictionary: ExpressionArgumentConvertible where Key == Double, + Value: ExpressionArgumentConvertible { public var expressionElements: [Expression.Element] { var elements = [Expression.Element]() for key in Array(keys).sorted(by: <) { diff --git a/Sources/MapboxMaps/Style/Types/ExpressionOptions.swift b/Sources/MapboxMaps/Style/Types/ExpressionOptions.swift index bfbdfa64e9c..0336bcd6ef3 100644 --- a/Sources/MapboxMaps/Style/Types/ExpressionOptions.swift +++ b/Sources/MapboxMaps/Style/Types/ExpressionOptions.swift @@ -43,7 +43,7 @@ extension Expression { } -public struct FormatOptions: Codable, Equatable, ValidExpressionArgument { +public struct FormatOptions: Codable, Equatable, ExpressionArgumentConvertible { /// Applies a scaling factor on text-size as specified by the root layout property. public var fontScale: Double? @@ -74,7 +74,7 @@ public struct FormatOptions: Codable, Equatable, ValidExpressionArgument { } } -public struct NumberFormatOptions: Codable, Equatable, ValidExpressionArgument { +public struct NumberFormatOptions: Codable, Equatable, ExpressionArgumentConvertible { /// Specifies the locale to use, as a BCP 47 language tag. public var locale: String? @@ -107,7 +107,7 @@ public struct NumberFormatOptions: Codable, Equatable, ValidExpressionArgument { } } -public struct CollatorOptions: Codable, Equatable, ValidExpressionArgument { +public struct CollatorOptions: Codable, Equatable, ExpressionArgumentConvertible { /// Whether comparison option is case sensitive. public var caseSensitive: Bool? diff --git a/Tests/MapboxMapsTests/Foundation/Camera/MapboxMapsCameraTests.swift b/Tests/MapboxMapsTests/Foundation/Camera/MapboxMapsCameraTests.swift index 6476def837f..03edf5b020f 100644 --- a/Tests/MapboxMapsTests/Foundation/Camera/MapboxMapsCameraTests.swift +++ b/Tests/MapboxMapsTests/Foundation/Camera/MapboxMapsCameraTests.swift @@ -15,7 +15,7 @@ class CameraManagerTests: XCTestCase { override func setUp() { resourceOptions = ResourceOptions(accessToken: "pk.feedcafedeadbeefbadebede") - mapView = BaseMapView(with: CGRect(x: 0, y: 0, width: 100, height: 100), + mapView = BaseMapView(frame: CGRect(x: 0, y: 0, width: 100, height: 100), resourceOptions: resourceOptions, glyphsRasterizationOptions: GlyphsRasterizationOptions.default, styleURI: nil) @@ -28,7 +28,7 @@ class CameraManagerTests: XCTestCase { mapView.zoom = 5.0 XCTAssertEqual(mapView.cameraView.localZoom, 5.0, "Camera's zoom value is not initialized.") - cameraManager.setCamera(zoom: 10.0) + cameraManager.setCamera(to: CameraOptions(zoom: 10.0)) XCTAssertEqual(mapView.cameraView.localZoom, 10.0, "Camera manager did not set camera view zoom value.") } @@ -60,73 +60,6 @@ class CameraManagerTests: XCTestCase { XCTAssertEqual(camera.pitch, 0) } - // The default bounds returned by getBounds() matches the coordinate bounds for one world. Disabling -// func testDefaultCameraBoundsRestrictionIsNil() { -// let cameraManager = CameraManager(for: mapView, with: MapCameraOptions()) -// -// let restrictedBounds = cameraManager.mapCameraOptions.restrictedCoordinateBounds -// XCTAssertNil(restrictedBounds, "Default camera options don't have set bounds restriction.") -// } - - func testCameraOptionRestrictedBoundsRejectsBounds() { - let restrictedBounds = CoordinateBounds(southwest: CLLocationCoordinate2D(latitude: 0, longitude: 0), - northeast: CLLocationCoordinate2D(latitude: 10, longitude: 10)) - - let outOfBounds = CoordinateBounds(southwest: CLLocationCoordinate2D(latitude: -10, longitude: -10), - northeast: CLLocationCoordinate2D(latitude: -5, longitude: -5)) - - var cameraOptions = MapCameraOptions() - cameraOptions.restrictedCoordinateBounds = restrictedBounds - let cameraManager = CameraManager(for: mapView, with: cameraOptions) - let previousCenter = mapView.centerCoordinate - cameraManager.transitionCoordinateBounds(newCoordinateBounds: outOfBounds) - let currentCenter = mapView.centerCoordinate - - // The bounds to set the camera view to falls outside the restricted bounds, - // so the center won't change since the call to `transitionVisibleCoordinateBounds(to:)` won't complete. - XCTAssertEqual(previousCenter.latitude, currentCenter.latitude, "Camera view center latitude did not change.") - XCTAssertEqual(previousCenter.longitude, - currentCenter.longitude, - "Camera view center longitude did not change.") - } - - func testCameraForCoordinateBounds() { - let cameraManager = CameraManager(for: mapView, with: MapCameraOptions()) - let southwest = CLLocationCoordinate2D(latitude: -10, longitude: -10) - let northeast = CLLocationCoordinate2D(latitude: 0, longitude: 0) - let coordinateBounds = CoordinateBounds(southwest: southwest, northeast: northeast) - - let camera = cameraManager.camera(for: coordinateBounds) - _ = cameraManager.fly(to: camera, completion: nil) - - XCTAssertNotNil(mapView.cameraView.camera) - - // Failing. See https://github.com/mapbox/mapbox-maps-internal/issues/396 -// XCTAssertEqual(mapView.cameraView.centerCoordinate.latitude, camera.centerCoordinate.latitude) -// XCTAssertEqual(mapView.cameraView.centerCoordinate.longitude, camera.centerCoordinate.longitude) - } - - func testCameraOptionRestrictedBoundsAcceptsBounds() { - let restrictedBounds = CoordinateBounds(southwest: CLLocationCoordinate2D(latitude: 0, longitude: 0), - northeast: CLLocationCoordinate2D(latitude: 10, longitude: 10)) - - let allowedBounds = CoordinateBounds(southwest: CLLocationCoordinate2D(latitude: 2, longitude: 2), - northeast: CLLocationCoordinate2D(latitude: 4, longitude: 4)) - - var cameraOptions = MapCameraOptions() - cameraOptions.restrictedCoordinateBounds = restrictedBounds - let cameraManager = CameraManager(for: mapView, with: cameraOptions) - let previousCenter = mapView.centerCoordinate - cameraManager.transitionCoordinateBounds(newCoordinateBounds: allowedBounds) - let currentCenter = mapView.cameraView.localCenterCoordinate - - // The bounds to set the camera view to falls within the restricted bounds, - // so the center will change. - XCTAssertNotEqual(previousCenter.latitude, currentCenter.latitude, "Camera view center latitude was changed.") - XCTAssertNotEqual(previousCenter.longitude, currentCenter.longitude, - "Camera view center longitude was changed.") - } - func testSetCamera() { let expectedCamera = CameraOptions(center: CLLocationCoordinate2D(latitude: 50, longitude: 50), padding: UIEdgeInsets(top: 1, left: 2, bottom: 3, right: 4), @@ -194,7 +127,7 @@ class CameraManagerTests: XCTestCase { func testSetCameraByComponentEnforcesMinZoom() { cameraManager.mapCameraOptions.minimumZoomLevel = CGFloat.random(in: 0.. 1 { - if case Exp.Element.op(_) = exp.elements[0] { + if case Exp.Element.operator(_) = exp.elements[0] { // First element is an operator } else { XCTFail("In all expressions, the first element MUST be an operator") @@ -95,29 +75,6 @@ internal class ExpressionTests: XCTestCase { expressionValidator(exp: expression) } - internal func testPerformanceOfRoundtripExpressionConversion() throws { - // This is an example of a performance test case. - measure { - let expression = Exp(.interpolate) { - Exp(.linear) - Exp(.zoom) - 0 - UIColor.red - 14 - UIColor.blue - } - - do { - let expressionAsJSON = try expression.jsonObject() - let expressionAgain = Expression(from: expressionAsJSON) - XCTAssert(expressionAgain != nil) - XCTAssert(expression == expressionAgain!) - } catch { - XCTFail("Failed to convert expression to JSON and back") - } - } - } - internal func testExpressionDecodingOnEmptyJSON() throws { let jsonString = @@ -145,7 +102,7 @@ internal class ExpressionTests: XCTestCase { // MARK: - Helpers internal func verifyExpressionOperator(for expression: Expression, toMatch type: Expression.Operator) { - guard let op = expression.elements.first, case let .op(validOp) = op else { + guard let op = expression.elements.first, case let .operator(validOp) = op else { XCTFail("There was no valid operator in the first element of the expression array") return } @@ -155,7 +112,7 @@ internal class ExpressionTests: XCTestCase { internal func verifyExpressionArgument(for expression: Expression, toMatch argument: Expression.Argument, at index: Int) { - guard let op = expression.elements.first, case .op = op else { + guard let op = expression.elements.first, case .operator = op else { XCTFail("There was no valid operator in the first element of the expression array") return } diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/BackgroundLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/BackgroundLayerIntegrationTests.swift index ea1e33e60dd..567a7bb4e54 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/BackgroundLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/BackgroundLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class BackgroundLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved BackgroundLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/CircleLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/CircleLayerIntegrationTests.swift index 79e3a9130e3..53b80bceabe 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/CircleLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/CircleLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class CircleLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved CircleLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillExtrusionLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillExtrusionLayerIntegrationTests.swift index b70c00521e7..c487d7765cb 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillExtrusionLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillExtrusionLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class FillExtrusionLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved FillExtrusionLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillLayerIntegrationTests.swift index f7ff6d85e65..06d8f9a9f13 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/FillLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class FillLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved FillLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HeatmapLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HeatmapLayerIntegrationTests.swift index 316da6ba35e..11e6237c672 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HeatmapLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HeatmapLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class HeatmapLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved HeatmapLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HillshadeLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HillshadeLayerIntegrationTests.swift index f8f1264d3af..c0dd30be5f5 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HillshadeLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/HillshadeLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class HillshadeLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved HillshadeLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LineLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LineLayerIntegrationTests.swift index 8714c56599a..95f85864826 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LineLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LineLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class LineLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved LineLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LocationIndicatorLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LocationIndicatorLayerIntegrationTests.swift index 37f5586d365..ec7c717f02f 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LocationIndicatorLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/LocationIndicatorLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class LocationIndicatorLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved LocationIndicatorLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/ModelLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/ModelLayerIntegrationTests.swift index 804f5170987..6c398a0a087 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/ModelLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/ModelLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class ModelLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved ModelLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/RasterLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/RasterLayerIntegrationTests.swift index 083ae45cf2e..c059a8bc950 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/RasterLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/RasterLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class RasterLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved RasterLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SkyLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SkyLayerIntegrationTests.swift index 7a9db309fdb..73446b2c863 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SkyLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SkyLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class SkyLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved SkyLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SymbolLayerIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SymbolLayerIntegrationTests.swift index 0a8fd9dca7a..008d37f3718 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SymbolLayerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Layers/SymbolLayerIntegrationTests.swift @@ -25,7 +25,7 @@ class SymbolLayerIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedLayerExpectation = XCTestExpectation(description: "Successfully retrieved SymbolLayer from Map") successfullyRetrievedLayerExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/GeoJsonSourceIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/GeoJsonSourceIntegrationTests.swift index 1d14ca43866..db553371a42 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/GeoJsonSourceIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/GeoJsonSourceIntegrationTests.swift @@ -23,7 +23,7 @@ class GeoJSONSourceIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedSourceExpectation = XCTestExpectation(description: "Successfully retrieved GeoJSONSource from Map") successfullyRetrievedSourceExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in var source = GeoJSONSource() diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/ImageSourceIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/ImageSourceIntegrationTests.swift index 718652c69bc..f17f27bfdf2 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/ImageSourceIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/ImageSourceIntegrationTests.swift @@ -23,7 +23,7 @@ class ImageSourceIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedSourceExpectation = XCTestExpectation(description: "Successfully retrieved ImageSource from Map") successfullyRetrievedSourceExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in var source = ImageSource() diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterDemSourceIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterDemSourceIntegrationTests.swift index aaefce8983c..e8786a7ff3f 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterDemSourceIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterDemSourceIntegrationTests.swift @@ -23,7 +23,7 @@ class RasterDemSourceIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedSourceExpectation = XCTestExpectation(description: "Successfully retrieved RasterDemSource from Map") successfullyRetrievedSourceExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in var source = RasterDemSource() diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterSourceIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterSourceIntegrationTests.swift index 46f9db5361e..d5e41f8bb5b 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterSourceIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/RasterSourceIntegrationTests.swift @@ -23,7 +23,7 @@ class RasterSourceIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedSourceExpectation = XCTestExpectation(description: "Successfully retrieved RasterSource from Map") successfullyRetrievedSourceExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in var source = RasterSource() diff --git a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/VectorSourceIntegrationTests.swift b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/VectorSourceIntegrationTests.swift index 33d55589581..cf2d7c0d314 100644 --- a/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/VectorSourceIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/Generated/IntegrationTests/Sources/VectorSourceIntegrationTests.swift @@ -23,7 +23,7 @@ class VectorSourceIntegrationTests: MapViewIntegrationTestCase { let successfullyRetrievedSourceExpectation = XCTestExpectation(description: "Successfully retrieved VectorSource from Map") successfullyRetrievedSourceExpectation.expectedFulfillmentCount = 1 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in var source = VectorSource() diff --git a/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift b/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift index fac5d71f41d..2f737e9546c 100644 --- a/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift @@ -18,7 +18,7 @@ internal class StyleIntegrationTests: MapViewIntegrationTestCase { let expectation = XCTestExpectation(description: "Manipulating style succeeded") expectation.expectedFulfillmentCount = 3 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in @@ -71,7 +71,7 @@ internal class StyleIntegrationTests: MapViewIntegrationTestCase { let expectation = XCTestExpectation(description: "Move style layer succeeded") expectation.expectedFulfillmentCount = 2 - style.styleURI = .streets + style.uri = .streets didFinishLoadingStyle = { _ in diff --git a/Tests/MapboxMapsTests/Style/StyleURITests.swift b/Tests/MapboxMapsTests/Style/StyleURITests.swift index 9dee36d06da..43b95ca09b4 100644 --- a/Tests/MapboxMapsTests/Style/StyleURITests.swift +++ b/Tests/MapboxMapsTests/Style/StyleURITests.swift @@ -55,7 +55,7 @@ class StyleURITests: XCTestCase { } XCTAssertEqual(destURL, sourceURL, line: line) - XCTAssertEqual(destURL, styleURI.url, line: line) + XCTAssertEqual(destURL, styleURI.rawValue.absoluteURL, line: line) } private func checkDefaultStyleURI(with URLString: String, expected: StyleURI, line: UInt = #line) {