Skip to content
Merged
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: 7 additions & 0 deletions ios/RNMBX/RNMBXCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ struct CameraUpdateItem {
try center.validate()
}

// Mapbox cancels camera animations immediately while the map view has no window
// (e.g. an inactive navigator screen), so jump to the target instead of dropping it.
if map.mapView.window == nil {
map.mapboxMap.setCamera(to: camera)
return
}

switch mode {
case .flight:
map.mapView.camera.fly(to: camera, duration: duration)
Expand Down
5 changes: 1 addition & 4 deletions ios/RNMBX/RNMBXImages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ open class RNMBXImages : UIView, RNMBXMapComponent {
}

lazy var placeholderImage : UIImage = {
UIGraphicsBeginImageContextWithOptions(CGSize(width: 1, height: 1), false, 0.0)
let result = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return result
UIGraphicsImageRenderer(size: CGSize(width: 1, height: 1)).image { _ in }
}()
}

Expand Down
12 changes: 6 additions & 6 deletions ios/RNMBX/RNMBXMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1578,13 +1578,13 @@ extension RNMBXMapView
@objc public func takeSnap(
writeToDisk:Bool) -> URL
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 0);

self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
let snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
let format = UIGraphicsImageRendererFormat(for: self.traitCollection)
format.opaque = true
let snapshot = UIGraphicsImageRenderer(bounds: self.bounds, format: format).image { _ in
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
}

return writeToDisk ? RNMBImageUtils.createTempFile(snapshot!) : RNMBImageUtils.createBase64(snapshot!)
return writeToDisk ? RNMBImageUtils.createTempFile(snapshot) : RNMBImageUtils.createBase64(snapshot)
}
}

Expand Down
Loading