@@ -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