@@ -419,6 +419,8 @@ export class HelloWorldModel extends Observable {
419
419
}
420
420
421
421
public doAddLayerAndSource ( ) : void {
422
+ try {
423
+
422
424
this . mapbox
423
425
. addSource ( 'custom-collection-1' , {
424
426
type : 'geojson' ,
@@ -506,34 +508,41 @@ export class HelloWorldModel extends Observable {
506
508
. then ( ( ) => console . log ( 'circle-layer-1 added to source custom-collection-1' ) ) ;
507
509
} ) ;
508
510
509
- this . mapbox . addLayer ( {
510
- id : 'layer-with-source-object' ,
511
- type : 'line' ,
512
- source : {
513
- type : 'geojson' ,
514
- data : {
515
- type : 'Feature' ,
516
- properties : { } ,
517
- geometry : {
518
- type : 'LineString' ,
519
- coordinates : [
520
- [ 4.80926513671875 , 52.27403984182285 ] ,
521
- [ 4.9383544921875 , 52.30931825948968 ] ,
522
- ] ,
523
- } ,
524
- }
525
- } ,
526
- layout : {
527
- 'line-cap' : 'square' ,
528
- 'line-join' : 'round' ,
529
- 'line-blur' : 15
530
- } ,
531
- paint : {
532
- 'line-color' : '#5dbcd2' ,
533
- 'line-width' : 8 ,
534
- 'line-opacity' : 0.5
511
+ this . mapbox . addLayer ( {
512
+ id : 'layer-with-source-object' ,
513
+ type : 'line' ,
514
+ source : {
515
+ type : 'geojson' ,
516
+ data : {
517
+ type : 'Feature' ,
518
+ properties : { } ,
519
+ geometry : {
520
+ type : 'LineString' ,
521
+ coordinates : [
522
+ [ 4.80926513671875 , 52.27403984182285 ] ,
523
+ [ 4.9383544921875 , 52.30931825948968 ] ,
524
+ ] ,
525
+ } ,
535
526
}
536
- } ) . then ( ( ) => console . log ( 'layer-with-source-object added' ) ) ;
527
+ } ,
528
+ layout : {
529
+ 'line-cap' : 'square' ,
530
+ 'line-join' : 'round' ,
531
+ 'line-blur' : 15
532
+ } ,
533
+ paint : {
534
+ 'line-color' : '#5dbcd2' ,
535
+ 'line-width' : 8 ,
536
+ 'line-opacity' : 0.5
537
+ }
538
+ } ) . then ( ( ) => console . log ( 'layer-with-source-object added' ) ) ;
539
+
540
+ } catch ( error ) {
541
+ console . error ( 'Mapbox doAddLayerAndSource error :' , error ) ;
542
+
543
+ }
544
+
545
+
537
546
}
538
547
539
548
public doRemoveLayerAndSource ( ) : void {
@@ -542,8 +551,10 @@ export class HelloWorldModel extends Observable {
542
551
this . mapbox . removeLayer ( 'circle-layer-1' ) ,
543
552
this . mapbox . removeLayer ( 'layer-with-source-object' )
544
553
] ) . then ( ( ) => {
545
- this . mapbox . removeSource ( 'custom-collection-1' ) ;
546
- this . mapbox . removeSource ( 'layer-with-source-object_source' ) ;
554
+ return Promise . all ( [
555
+ this . mapbox . removeSource ( 'custom-collection-1' ) ,
556
+ this . mapbox . removeSource ( 'layer-with-source-object_source' )
557
+ ] ) ;
547
558
} )
548
559
}
549
560
0 commit comments