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

Change MapStyle #34

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -102,12 +103,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
Loading