From 51e52941402f7bd8bb89b206677c8609a503626c Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Sun, 27 Oct 2024 15:15:06 +0530 Subject: [PATCH] Fix[iOS]: get visit bounds (#3664) --- ios/RNMBX/RNMBXMapViewManager.swift | 7 +++++-- ios/RNMBX/RNMBXMapViewModule.mm | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ios/RNMBX/RNMBXMapViewManager.swift b/ios/RNMBX/RNMBXMapViewManager.swift index 53834dfdb..4306b9057 100644 --- a/ios/RNMBX/RNMBXMapViewManager.swift +++ b/ios/RNMBX/RNMBXMapViewManager.swift @@ -111,8 +111,11 @@ extension RNMBXMapViewManager { @objc public static func getVisibleBounds( _ view: RNMBXMapView, - resolver: @escaping RCTPromiseResolveBlock) { - resolver(["visibleBounds": view.mapboxMap.coordinateBounds(for: view.bounds).toArray()]) + resolver: @escaping RCTPromiseResolveBlock, + rejecter: @escaping RCTPromiseRejectBlock) { + view.withMapboxMap { map in + resolver(["visibleBounds": map.coordinateBounds(for: view.bounds).toArray()]) + } } } diff --git a/ios/RNMBX/RNMBXMapViewModule.mm b/ios/RNMBX/RNMBXMapViewModule.mm index 21cb8f1ad..ec622d223 100644 --- a/ios/RNMBX/RNMBXMapViewModule.mm +++ b/ios/RNMBX/RNMBXMapViewModule.mm @@ -87,7 +87,7 @@ - (void)withMapView:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXMapView *))b RCT_EXPORT_METHOD(getVisibleBounds:(nonnull NSNumber*)viewRef resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { [self withMapView:viewRef block:^(RNMBXMapView *view) { - [RNMBXMapViewManager getVisibleBounds:view resolver:resolve]; + [RNMBXMapViewManager getVisibleBounds:view resolver:resolve rejecter:reject]; } reject:reject methodName:@"getVisibleBounds"]; }