Skip to content

Commit fa6e38d

Browse files
author
fonok3
committed
🔖 1.1.0 [ci skip]
1 parent d8791ff commit fa6e38d

File tree

7 files changed

+64
-7
lines changed

7 files changed

+64
-7
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
public struct CameraConfiguration {
4+
public enum Perspective: Int, CaseIterable, Codable {
5+
case threeDimensional
6+
case twoDimensional
7+
case twoDimensionalNorth
8+
}
9+
10+
// MARK: Lifecycle
11+
12+
public init(zoomLevelOffset: Double = 0, perspective: Perspective = .threeDimensional) {
13+
self.zoomLevelOffset = zoomLevelOffset
14+
self.perspective = perspective
15+
}
16+
17+
// MARK: Public
18+
19+
public let zoomLevelOffset: Double
20+
public let perspective: Perspective
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
public protocol CameraConfigurationProvider {
4+
var cameraConfiguration: CameraConfiguration { get }
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Foundation
2+
3+
public final class StaticCameraConfigurationProvider: CameraConfigurationProvider {
4+
// MARK: Lifecycle
5+
6+
public init(cameraConfiguration: CameraConfiguration = CameraConfiguration()) {
7+
self.cameraConfiguration = cameraConfiguration
8+
}
9+
10+
// MARK: Public
11+
12+
public let cameraConfiguration: CameraConfiguration
13+
}

Sources/GMMapUtility/Layers/Handler/AggregatingMGLStyleLayersHandler.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ open class AggregatingMGLStyleLayersHandler: MGLStyleLayersHandler {
66

77
public init(
88
mapLayerManager: MapboxMapLayerManager?,
9+
mapTheme: MapTheme,
910
layerHandlers: [MGLStyleLayersHandler]
1011
) {
1112
self.layerHandlers = layerHandlers
12-
super.init(mapLayerManager: mapLayerManager)
13+
super.init(mapLayerManager: mapLayerManager, mapTheme: mapTheme)
1314
}
1415

1516
override open func setup() {

Sources/GMMapUtility/Layers/Handler/MapLayerHandler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Foundation
44
///
55
/// - note: A `MapLayerHandler` may be self updating to model changes or receive udpates from outside. Often these two purposes are split up.
66
public protocol MapLayerHandler {
7+
var mapTheme: MapTheme { get }
8+
79
/// One time setup for all needed resources for handling the layer, e.g. images, sources.
810
func setup()
911

Sources/GMMapUtility/MapLibre/Layers/MGLMapViewLifeCycleHandler.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public final class MGLMapViewLifeCycleHandler: NSObject {
1818
public weak var mapView: MGLMapView?
1919

2020
private var currentLayersController: MGLStyleLayersHandler?
21+
private var layerUpdatesPaused = true {
22+
didSet {
23+
if layerUpdatesPaused {
24+
currentLayersController?.stopLayerUpdates()
25+
} else {
26+
currentLayersController?.startLayerUpdates()
27+
}
28+
}
29+
}
2130

2231
private lazy var mapTapGestureRecognizer: UITapGestureRecognizer = {
2332
let recognizer = UITapGestureRecognizer(target: self, action: #selector(didTapMapView(sender:)))
@@ -53,16 +62,16 @@ public final class MGLMapViewLifeCycleHandler: NSObject {
5362
extension MGLMapViewLifeCycleHandler {
5463
/// This methods pauses all layer updates.
5564
///
56-
/// - note: This may be called if the map is not visible.
65+
/// - note: This shoud be called if the map is not visible.
5766
public func pauseLayerUpdates() {
58-
currentLayersController?.startLayerUpdates()
67+
layerUpdatesPaused = true
5968
}
6069

6170
/// This methods resumes all layer updates.
6271
///
63-
/// - note: This may be called if the map becomes visible.
72+
/// - note: This should be called if the map becomes visible.
6473
public func resumeLayerUpdates() {
65-
currentLayersController?.stopLayerUpdates()
74+
layerUpdatesPaused = false
6675
}
6776
}
6877

@@ -78,7 +87,10 @@ extension MGLMapViewLifeCycleHandler {
7887
)
7988

8089
currentLayersController?.setup()
81-
currentLayersController?.startLayerUpdates()
90+
91+
if !layerUpdatesPaused {
92+
currentLayersController?.startLayerUpdates()
93+
}
8294
}
8395

8496
private func localize(style: MGLStyle) {

Sources/GMMapUtility/MapLibre/Layers/MGLStyleLayersHandler.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import Foundation
22
import Mapbox
33

44
open class MGLStyleLayersHandler: MapLayerHandler {
5+
public private(set) var mapTheme: MapTheme
6+
57
public private(set) var mapLayerManager: MapboxMapLayerManager?
68

79
open var interactionLayerIdentifiers: Set<String> { Set<String>([]) }
810

9-
public init(mapLayerManager: MapboxMapLayerManager?) {
11+
public init(mapLayerManager: MapboxMapLayerManager?, mapTheme: MapTheme) {
1012
self.mapLayerManager = mapLayerManager
13+
self.mapTheme = mapTheme
1114
}
1215

1316
// MARK: - User Interaction

0 commit comments

Comments
 (0)