From ac8172e820d15d36c0b68d71cdd7885138f981d7 Mon Sep 17 00:00:00 2001 From: Wykks Date: Fri, 17 Nov 2017 22:54:16 +0100 Subject: [PATCH] fix(geojsonSource): protect onDestroy fix #6 --- src/app/lib/source/geojson/geojson-source.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/lib/source/geojson/geojson-source.component.ts b/src/app/lib/source/geojson/geojson-source.component.ts index e15847b08..afb4c8b7e 100644 --- a/src/app/lib/source/geojson/geojson-source.component.ts +++ b/src/app/lib/source/geojson/geojson-source.component.ts @@ -82,8 +82,10 @@ export class GeoJSONSourceComponent implements OnInit, OnDestroy, OnChanges, Geo } ngOnDestroy() { - this.sub.unsubscribe(); - this.MapService.removeSource(this.id); + if (this.sourceAdded) { + this.sub.unsubscribe(); + this.MapService.removeSource(this.id); + } } addFeature(feature: GeoJSON.Feature) {