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

fix: make mapboxMap property optional in map view accessor #3377

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 5 additions & 2 deletions ios/RNMBX/RNMBXCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ struct CameraUpdateItem {
map.mapView.camera.ease(to: camera, duration: duration ?? 0, curve: .easeInOut, completion: nil)
case .linear:
map.mapView.camera.ease(to: camera, duration: duration ?? 0, curve: .linear, completion: nil)
default:
map.mapboxMap.setCamera(to: camera)
default:
if let mapboxMap = map.mapboxMap {
mapboxMap.setCamera(to: camera)
}

}
}
}
Expand Down
5 changes: 3 additions & 2 deletions ios/RNMBX/RNMBXImageSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ public class RNMBXImageSource : RNMBXSource {

func doUpdate(_ update:(Style) -> Void) {
guard let map = self.map,
let mapboxMap = map.mapboxMap,
let _ = self.source,
map.mapboxMap.style.sourceExists(withId: id) else {
mapboxMap.style.sourceExists(withId: id) else {
return
}

let style = map.mapboxMap.style
let style = mapboxMap.style
update(style)
}

Expand Down
2 changes: 1 addition & 1 deletion ios/RNMBX/RNMBXInteractiveElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RNMBXInteractiveElement : UIView, RNMBXMapComponent {
}
didSet {
if oldValue != nil && oldValue != id {
if let map = map { addToMap(map, style: map.mapboxMap.style) }
if let map = map, let mapboxMap = map.mapboxMap { addToMap(map, style: mapboxMap.style) }
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion ios/RNMBX/RNMBXLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ public class RNMBXLayer : UIView, RNMBXMapComponent, RNMBXSourceConsumer {
}

public func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
removeFromMap(map.mapboxMap.style)
if let mapboxMap = map.mapboxMap {
removeFromMap(mapboxMap.style)
}

return true
}

Expand Down
Loading
Loading