Skip to content

Commit 0fc5aee

Browse files
committed
fix(map): get the bubble map back (thanks to @SUlbrichA)
Closes #1576
1 parent bb9dccf commit 0fc5aee

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

.angular-cli.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"../node_modules/tinymce/plugins/paste/plugin.min.js",
4343
"../node_modules/tinymce/plugins/table/plugin.min.js",
4444
"../node_modules/echarts/dist/echarts.min.js",
45+
"../node_modules/echarts/dist/extension/bmap.min.js",
4546
"../node_modules/chart.js/dist/Chart.min.js"
4647
],
4748
"environmentSource": "environments/environment.ts",

src/app/pages/maps/bubble/bubble-map.component.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { Component, OnDestroy } from '@angular/core';
2+
import { HttpClient } from '@angular/common/http';
3+
import { combineLatest } from 'rxjs/observable/combineLatest';
4+
import { takeWhile } from 'rxjs/operators/takeWhile';
5+
import { NgxEchartsService } from 'ngx-echarts';
26
import { NbThemeService } from '@nebular/theme';
37

48
@Component({
@@ -23,12 +27,22 @@ export class BubbleMapComponent implements OnDestroy {
2327

2428
bubbleTheme: any;
2529
geoColors: any[];
26-
themeSubscription: any;
2730

28-
constructor(private theme: NbThemeService) {
31+
private alive = true;
2932

30-
this.themeSubscription = this.theme.getJsTheme()
31-
.subscribe(config => {
33+
constructor(private theme: NbThemeService,
34+
private http: HttpClient,
35+
private es: NgxEchartsService) {
36+
37+
38+
combineLatest([
39+
this.http.get('assets/map/world.json'),
40+
this.theme.getJsTheme(),
41+
])
42+
.pipe(takeWhile(() => this.alive))
43+
.subscribe(([map, config]: [any, any]) => {
44+
45+
this.es.registerMap('world', map);
3246

3347
const colors = config.variables;
3448
this.bubbleTheme = config.variables.bubbleMap;
@@ -527,7 +541,7 @@ export class BubbleMapComponent implements OnDestroy {
527541
}
528542

529543
ngOnDestroy() {
530-
this.themeSubscription.unsubscribe();
544+
this.alive = false;
531545
}
532546

533547
private getRandomGeoColor() {

src/assets/map/world.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)