Skip to content

Commit

Permalink
Merge pull request maplibre#34 from hactar/change-mapstyle
Browse files Browse the repository at this point in the history
Change MapStyle
  • Loading branch information
ianthetechie authored Apr 16, 2024
2 parents c7fc6a0 + f6b8b09 commit 1ebefd1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/MapLibreSwiftUI/MapViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MapViewCoordinator: NSObject {
// every update cycle so we can avoid unnecessary updates
private var snapshotUserLayers: [StyleLayerDefinition] = []
private var snapshotCamera: MapViewCamera?
private var snapshotStyleSource: MapStyleSource?

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

@MainActor func updateStyleSource(_ source: MapStyleSource, mapView: MLNMapView) {
switch (source, parent.styleSource) {
switch (source, snapshotStyleSource) {
case let (.url(newURL), .url(oldURL)):
if newURL != oldURL {
mapView.styleURL = newURL
}
case let (.url(newURL), .none):
mapView.styleURL = newURL
}

snapshotStyleSource = source
}

@MainActor func updateLayers(mapView: MLNMapView) {
Expand Down

0 comments on commit 1ebefd1

Please sign in to comment.