Skip to content

Commit f67277c

Browse files
committed
fix(ios): removed many unwanted error message (no actual error)
1 parent 95b0b43 commit f67277c

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public class MapboxBridge: NSObject {
592592
guard let mv = mapView else { completion(false, NSError(domain: "MapboxBridge", code: 1, userInfo: [NSLocalizedDescriptionKey: "No map available"])); return }
593593
mv.mapboxMap.onStyleLoaded.observeNext { _ in completion(true, nil) }.store(in: &cancelables)
594594
mv.mapboxMap.loadStyle(getMapStyleURI(styleURIorURL));
595-
completion(false, NSError(domain: "MapboxBridge", code: 2, userInfo: [NSLocalizedDescriptionKey: "Invalid style string"]))
595+
// completion(false, NSError(domain: "MapboxBridge", code: 2, userInfo: [NSLocalizedDescriptionKey: "Invalid style string"]))
596596
}
597597

598598
// MARK: - Camera / viewport / animateCamera
@@ -953,14 +953,14 @@ public class MapboxBridge: NSObject {
953953
return true
954954

955955
}
956-
@objc public func removePolygons(_ _ids: [String]?) {
957-
guard let manager = polygonAnnotationManager else { return }
956+
@objc public func removePolygons(_ _ids: [String]?) -> Bool {
957+
guard let manager = polygonAnnotationManager else { return false }
958958
guard let ids = _ids else {
959959
manager.annotations.removeAll()
960960
if let outlineManager = polygonOutlineAnnotationManager {
961961
outlineManager.annotations.removeAll()
962962
}
963-
return
963+
return true
964964
}
965965
// guard let data = idsJSON!.data(using: .utf8) else { return }
966966
// guard let ids = try? JSONSerialization.jsonObject(with: data, options: []) as! [String] else { return }
@@ -977,18 +977,20 @@ public class MapboxBridge: NSObject {
977977
if let outlineManager = polygonOutlineAnnotationManager {
978978
outlineManager.annotations.removeAll { idSet.contains($0.id) }
979979
}
980+
return true
980981
}
981982

982-
@objc public func removePolylines(_ _ids: [String]?) {
983-
guard let manager = polylineAnnotationManager else { return }
983+
@objc public func removePolylines(_ _ids: [String]?) -> Bool {
984+
guard let manager = polylineAnnotationManager else { return false }
984985
guard let ids = _ids else {
985986
manager.annotations.removeAll()
986-
return
987+
return true
987988
}
988989

989990
let idSet = Set<String>(ids)
990991

991992
manager.annotations.removeAll { idSet.contains($0.id) }
993+
return true
992994
}
993995

994996
enum GeoJSONSourceUpdateError: Error {

src/ui-mapbox/index.ios.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ export class MapboxView extends MapboxViewBase {
182182

183183
async disposeNativeView(): Promise<void> {
184184
this.nativeView.owner = null;
185-
if (this.mapbox) await this.mapbox.destroy();
185+
this.mapbox?.destroy();
186+
this.mapbox = null;
186187
super.disposeNativeView();
187188
}
188189

@@ -468,7 +469,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
468469
nativeMap.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
469470

470471
_markers = [];
471-
this.addMarkers(settings.markers);
472+
this.addMarkers(settings.markers || []);
472473
// setTimeout(() => view.addSubview(nativeMap), 0);
473474
view.addSubview(nativeMap);
474475
this.setMapboxViewInstance(nativeMap);
@@ -532,22 +533,23 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
532533
this._programmaticMapView = null;
533534
}
534535
const bridge = MapboxBridge.bridgeFor(theMap);
535-
bridge.destroy();
536-
if (bridge === this.bridgeInstance) {
537-
this.bridgeInstance = null;
536+
if (Trace.isEnabled()) {
537+
CLog(CLogTypes.info, 'destroy():', theMap, bridge);
538538
}
539-
try {
540-
this._observerTokens.forEach((t) => {
541-
try {
542-
NSNotificationCenter.defaultCenter.removeObserver(t);
543-
} catch (e) {
544-
console.error(e, e.stack);
545-
}
546-
});
547-
this._observerTokens = [];
548-
} catch (e) {
549-
console.error(e, e.stack);
539+
if (bridge) {
540+
bridge.destroy();
541+
if (bridge === this.bridgeInstance) {
542+
this.bridgeInstance = null;
543+
}
550544
}
545+
this._observerTokens.forEach((t) => {
546+
try {
547+
NSNotificationCenter.defaultCenter.removeObserver(t);
548+
} catch (e) {
549+
console.error(e, e.stack);
550+
}
551+
});
552+
this._observerTokens = [];
551553

552554
if (this._reusableCalloutView) {
553555
this._reusableCalloutView._tearDownUI();
@@ -1101,12 +1103,19 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
11011103
reject('No bridge available');
11021104
return;
11031105
}
1106+
if (Trace.isEnabled()) {
1107+
CLog(CLogTypes.info, 'setMapStyle():', style);
1108+
}
11041109
const styleStr = (typeof style === 'string' ? style : (style as any).toString()) ?? 'streets';
11051110
b.setStyle(styleStr, (success: boolean, error?: any) => {
1111+
if (Trace.isEnabled()) {
1112+
CLog(CLogTypes.info, 'setMapStyle():', style, 'done:', success, error);
1113+
}
11061114
if (success) resolve();
11071115
else reject(error && error.localizedDescription ? error.localizedDescription : error || 'Error setting style');
11081116
});
11091117
} catch (ex) {
1118+
console.error('setMapStyle():', ex, ex['stack']);
11101119
reject(ex);
11111120
}
11121121
});

0 commit comments

Comments
 (0)