Skip to content

Commit 47b98b5

Browse files
pjleonard37Release SDK bot for Maps SDK team
authored andcommitted
Update iOS examples to Standard (#5101)
https://mapbox.atlassian.net/browse/MAPSIOS-1882 This PR updates our examples to use the Standard style with configurations applied to match their previous styles as much as possible. Now, the only examples left that use classic styles need them for a specific reason (QRF, layer placement, image asset in a specific style, etc.). cc @mapbox/maps-ios Co-authored-by: Release SDK bot for Maps SDK team <[email protected]> GitOrigin-RevId: fce5c7ed22ea579025d2b4f77396c40fd07f9139
1 parent c96201c commit 47b98b5

30 files changed

+90
-55
lines changed

Sources/Examples/All Examples/AnimateImageLayerExample.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ final class AnimateImageLayerExample: UIViewController, ExampleProtocol {
1313

1414
let center = CLLocationCoordinate2D(latitude: 41.874, longitude: -75.789)
1515
let cameraOptions = CameraOptions(center: center, zoom: 5)
16-
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: .dark)
16+
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions)
1717
mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
18+
mapView.mapboxMap.mapStyle = .standard(theme: .monochrome, lightPreset: .night)
1819
mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
1920

2021
// Hide the `scaleBar` at all zoom levels.
@@ -59,6 +60,10 @@ final class AnimateImageLayerExample: UIViewController, ExampleProtocol {
5960
// Set `rasterFadeDuration` to `0`. This prevents visible transitions when the image is updated.
6061
imageLayer.rasterFadeDuration = .constant(0)
6162

63+
// `LightPreset`s are applied to all layers of the map.
64+
// As `.night` is applied we need to set `rasterEmissiveStrength` to color the image
65+
imageLayer.rasterEmissiveStrength = .constant(1)
66+
6267
do {
6368
try mapView.mapboxMap.addSource(imageSource)
6469
try mapView.mapboxMap.addLayer(imageLayer)

Sources/Examples/All Examples/AnimateLayerExample.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ final class AnimateLayerExample: UIViewController, ExampleProtocol {
1212
let centerCoordinate = CLLocationCoordinate2D(latitude: 37.8, longitude: -96)
1313
let options = MapInitOptions(cameraOptions: CameraOptions(center: centerCoordinate,
1414
zoom: 2),
15+
// The Streets style contains the airplane icon
1516
styleURI: .streets)
1617

1718
mapView = MapView(frame: view.bounds, mapInitOptions: options)

Sources/Examples/All Examples/Annotations/AddMarkersSymbolExample.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ final class AddMarkersSymbolExample: UIViewController, ExampleProtocol {
2222
// The following line is just for testing purposes.
2323
self.finish()
2424
}.store(in: &cancelables)
25-
26-
mapView.mapboxMap.styleURI = .streets
2725
}
2826

2927
// MARK: - Style management

Sources/Examples/All Examples/Annotations/AnimatedMarkerExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class AnimatedMarkerExample: UIViewController, ExampleProtocol {
4848
label.centerXAnchor.constraint(equalTo: view.centerXAnchor)
4949
])
5050

51-
mapView.mapboxMap.loadStyle(.satelliteStreets)
51+
mapView.mapboxMap.mapStyle = .standardSatellite
5252

5353
// add a tap gesture handler that will allow the marker to be animated
5454
mapView.mapboxMap.addInteraction(TapInteraction { [weak self] context in

Sources/Examples/All Examples/Annotations/IconSizeChangeExample.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class IconSizeChangeExample: UIViewController, ExampleProtocol {
1313
let cameraOptions = CameraOptions(center: initialPosition, zoom: 11)
1414
let initOptions = MapInitOptions(cameraOptions: cameraOptions)
1515
mapView = MapView(frame: view.bounds, mapInitOptions: initOptions)
16+
mapView.mapboxMap.mapStyle = .standard(theme: .monochrome, lightPreset: .night)
1617
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
1718
view.addSubview(mapView)
1819

@@ -25,8 +26,6 @@ final class IconSizeChangeExample: UIViewController, ExampleProtocol {
2526
// The below line is used for internal testing purposes only.
2627
self?.finish()
2728
}.store(in: &cancelables)
28-
29-
mapView.mapboxMap.loadStyle(.dark)
3029
}
3130

3231
private func setupExample() {

Sources/Examples/All Examples/Annotations/LineAnnotationExample.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class LineAnnotationExample: UIViewController, ExampleProtocol {
99
super.viewDidLoad()
1010

1111
let cameraOptions = CameraOptions(center: CLLocationCoordinate2D(latitude: 0, longitude: 0), zoom: 2)
12-
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: .streets)
12+
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions)
1313
mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
1414
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
1515
view.addSubview(mapView)
@@ -62,10 +62,7 @@ final class LineAnnotationExample: UIViewController, ExampleProtocol {
6262
// Annotation managers are kept alive by `AnnotationOrchestrator`
6363
// (`mapView.annotations`) until you explicitly destroy them
6464
// by calling `mapView.annotations.removeAnnotationManager(withId:)`
65-
let lineAnnnotationManager = mapView.annotations.makePolylineAnnotationManager(
66-
// position line annotations layer in a way that line annotations clipped at land borders
67-
layerPosition: .below("pitch-outline")
68-
)
65+
let lineAnnnotationManager = mapView.annotations.makePolylineAnnotationManager()
6966

7067
// Sync the annotation to the manager.
7168
lineAnnnotationManager.annotations = annotations

Sources/Examples/All Examples/Annotations/PointAnnotationClusteringExample.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ final class PointAnnotationClusteringExample: UIViewController, ExampleProtocol
1212
// Center the map over Washington, D.C.
1313
let center = CLLocationCoordinate2D(latitude: 38.889215, longitude: -77.039354)
1414
let cameraOptions = CameraOptions(center: center, zoom: 11)
15-
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: .light)
15+
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions)
1616
mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
17+
mapView.mapboxMap.mapStyle = .standard(theme: .monochrome)
1718
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
1819

1920
view.addSubview(mapView)

Sources/Examples/All Examples/Annotations/SymbolClusteringExample.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ final class SymbolClusteringExample: UIViewController, ExampleProtocol {
1111
// Create a `MapView` centered over Washington, DC.
1212
let center = CLLocationCoordinate2D(latitude: 38.889215, longitude: -77.039354)
1313
let cameraOptions = CameraOptions(center: center, zoom: 11)
14-
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: .dark)
14+
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions)
1515
mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
16+
mapView.mapboxMap.mapStyle = .standard(theme: .monochrome, lightPreset: .night)
1617
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
1718

1819
view.addSubview(mapView)
@@ -124,6 +125,10 @@ final class SymbolClusteringExample: UIViewController, ExampleProtocol {
124125

125126
clusteredLayer.circleRadius = .constant(25)
126127

128+
// `LightPreset`s are applied to all layers of the map.
129+
// As `.night` is applied we need to set `circleEmissiveStrength` to color the circles
130+
clusteredLayer.circleEmissiveStrength = .constant(1)
131+
127132
return clusteredLayer
128133
}
129134

@@ -146,6 +151,10 @@ final class SymbolClusteringExample: UIViewController, ExampleProtocol {
146151
360
147152
})
148153

154+
// `LightPreset`s are applied to all layers of the map.
155+
// As `.night` is applied we need to set `iconEmissiveStrength` to color the symbols
156+
unclusteredLayer.iconEmissiveStrength = .constant(1)
157+
149158
return unclusteredLayer
150159
}
151160

Sources/Examples/All Examples/Annotations/ViewAnnotationMarkerExample.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
5959
self?.handleMarkerTap(feature) ?? false
6060
})
6161

62-
mapView.mapboxMap.styleURI = .streets
63-
6462
view.addSubview(styleChangeButton)
6563

6664
NSLayoutConstraint.activate([
@@ -81,7 +79,7 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
8179
}
8280

8381
@objc private func styleChangePressed(sender: UIButton) {
84-
mapView.mapboxMap.styleURI = mapView.mapboxMap.styleURI == .streets ? .satelliteStreets : .streets
82+
mapView.mapboxMap.mapStyle = mapView.mapboxMap.mapStyle == .standard ? .standardSatellite : .standard
8583
}
8684

8785
// MARK: - Style management
@@ -93,7 +91,7 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
9391
source.data = .featureCollection(FeatureCollection(features: pointList))
9492
try? mapView.mapboxMap.addSource(source)
9593

96-
if mapView.mapboxMap.styleURI == .satelliteStreets {
94+
if mapView.mapboxMap.mapStyle == .standardSatellite {
9795
var demSource = RasterDemSource(id: "terrain-source")
9896
demSource.url = Constants.TERRAIN_URL_TILE_RESOURCE
9997
try? mapView.mapboxMap.addSource(demSource)

Sources/Examples/All Examples/Annotations/ViewAnnotationWithPointAnnotationExample.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ final class ViewAnnotationWithPointAnnotationExample: UIViewController, ExampleP
3939
}
4040
return false
4141
})
42-
43-
mapView.mapboxMap.styleURI = .streets
4442
}
4543

4644
// MARK: - Annotation management

0 commit comments

Comments
 (0)