javascript - How to destroy mapbox gl map instance - Stack Overflow

I am using "mapbox-gl": "^0.54.0".While initializing Mapboxgl instance no of web w

I am using "mapbox-gl": "^0.54.0". While initializing Mapboxgl instance no of web worker thread got created. please see the below image .

here is the sample code. gis-mapponent.html

<div #container id="GisMapContainer">

</div>

gis-mapponent.ts

import * as MapboxGl from 'mapbox-gl';

@Component({
  selector: 'gis-map',
  templateUrl: './gis-mapponent.html',
  styleUrls: ['./gis-mapponent.scss']
})
export class MapComponent implements OnInit, OnDestroy {

@ViewChild('container', {static: true}) mapContainer: ElementRef;

ngOnInit(){
let options={
container: this.mapContainer.nativeElement,
...
...
};
this.mapInstance = new MapboxGl.Map(options);
}

ngOnDestroy(){
this.mapInstance=null;
}

}

Now if i am destroying mapbox gl map instance on ponent destroy but these worker thread instance still exists.

Please give me suggestion it is possible to destroy Javascript vm web worker thread instance.

Thanks.

I am using "mapbox-gl": "^0.54.0". While initializing Mapboxgl instance no of web worker thread got created. please see the below image .

here is the sample code. gis-map.ponent.html

<div #container id="GisMapContainer">

</div>

gis-map.ponent.ts

import * as MapboxGl from 'mapbox-gl';

@Component({
  selector: 'gis-map',
  templateUrl: './gis-map.ponent.html',
  styleUrls: ['./gis-map.ponent.scss']
})
export class MapComponent implements OnInit, OnDestroy {

@ViewChild('container', {static: true}) mapContainer: ElementRef;

ngOnInit(){
let options={
container: this.mapContainer.nativeElement,
...
...
};
this.mapInstance = new MapboxGl.Map(options);
}

ngOnDestroy(){
this.mapInstance=null;
}

}

Now if i am destroying mapbox gl map instance on ponent destroy but these worker thread instance still exists.

Please give me suggestion it is possible to destroy Javascript vm web worker thread instance.

Thanks.

Share Improve this question edited Jul 15, 2020 at 16:22 cj devin asked Jun 18, 2020 at 10:23 cj devincj devin 1,3754 gold badges17 silver badges58 bronze badges 1
  • instead of setting map instance null,using remove() method this.mapInstance.remove() it's working fine.. github – cj devin Commented Jul 15, 2020 at 16:23
Add a ment  | 

1 Answer 1

Reset to default 4

this.mapInstance=null; is Okay but it will not destroy and release all resources(Events.. etc..) associated with this map.

Use instance member of Mapbox-gl-js: https://docs.mapbox./mapbox-gl-js/api/map/#map#remove

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744241952a4564747.html

相关推荐

  • javascript - How to destroy mapbox gl map instance - Stack Overflow

    I am using "mapbox-gl": "^0.54.0".While initializing Mapboxgl instance no of web w

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信