Skip to content

Commit 1ebefd1

Browse files
authored
Merge pull request #34 from hactar/change-mapstyle
Change MapStyle
2 parents c7fc6a0 + f6b8b09 commit 1ebefd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/MapLibreSwiftUI/MapViewCoordinator.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class MapViewCoordinator: NSObject {
1111
// every update cycle so we can avoid unnecessary updates
1212
private var snapshotUserLayers: [StyleLayerDefinition] = []
1313
private var snapshotCamera: MapViewCamera?
14+
private var snapshotStyleSource: MapStyleSource?
1415

1516
// Indicates whether we are currently in a push-down camera update cycle.
1617
// This is necessary in order to ensure we don't keep trying to reset a state value which we were already processing
@@ -105,12 +106,16 @@ public class MapViewCoordinator: NSObject {
105106
// MARK: - Coordinator API - Styles + Layers
106107

107108
@MainActor func updateStyleSource(_ source: MapStyleSource, mapView: MLNMapView) {
108-
switch (source, parent.styleSource) {
109+
switch (source, snapshotStyleSource) {
109110
case let (.url(newURL), .url(oldURL)):
110111
if newURL != oldURL {
111112
mapView.styleURL = newURL
112113
}
114+
case let (.url(newURL), .none):
115+
mapView.styleURL = newURL
113116
}
117+
118+
snapshotStyleSource = source
114119
}
115120

116121
@MainActor func updateLayers(mapView: MLNMapView) {

0 commit comments

Comments
 (0)