Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Cleanup #250

Merged
merged 19 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Apps/DebugApp/DebugApp/DebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ 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)

// Set the map's center coordinate and zoom level
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
Expand Down
4 changes: 2 additions & 2 deletions Apps/Examples/Examples/All Examples/BasicMapExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ 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)

// Center the map over the United States.
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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ 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)

// Center the map over the United States.
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions Apps/Examples/Examples/All Examples/FlyToExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions Apps/Examples/Examples/All Examples/LayerBelowExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ 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
let centerCoordinate = CLLocationCoordinate2D(latitude: 35.137452,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ 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)

// Center the map over the United States.
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Apps/Examples/Examples/All Examples/MapViewExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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.
Expand Down