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
1 Answer
Reset to default 4this.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
评论列表(0条)