Skip to content

Commit

Permalink
Fix crash setting zoomEnabled on MapView creation (#3269)
Browse files Browse the repository at this point in the history
  • Loading branch information
davegurnell authored Dec 14, 2023
1 parent 3bee422 commit 03a8f2e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ios/RNMBX/RNMBXMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ open class RNMBXMapView: UIView {
case scaleBar
case onLongPress
case onPress
case zoomEnabled
case scrollEnabled
case rotateEnabled
case pitchEnabled
Expand All @@ -298,6 +299,8 @@ open class RNMBXMapView: UIView {
map.applyOnLongPress()
case .onPress:
map.applyOnPress()
case .zoomEnabled:
map.applyZoomEnabled()
case .scrollEnabled:
map.applyScrollEnabled()
case .rotateEnabled:
Expand Down Expand Up @@ -661,10 +664,18 @@ open class RNMBXMapView: UIView {
changes.apply(self)
}

var zoomEnabled: Bool? = nil
@objc public func setReactZoomEnabled(_ value: Bool) {
self.mapView.gestures.options.quickZoomEnabled = value
self.mapView.gestures.options.doubleTapToZoomInEnabled = value
self.mapView.gestures.options.pinchZoomEnabled = value
self.zoomEnabled = value
changed(.zoomEnabled)
}

func applyZoomEnabled() {
if let value = zoomEnabled {
self.mapView.gestures.options.quickZoomEnabled = value
self.mapView.gestures.options.doubleTapToZoomInEnabled = value
self.mapView.gestures.options.pinchZoomEnabled = value
}
}

var scrollEnabled: Bool? = nil
Expand Down

0 comments on commit 03a8f2e

Please sign in to comment.