Skip to content

Commit 19f9d0e

Browse files
authored
fix(map): get the bubble map back (thanks to @SUlbrichA) (#1655)
Closes #1576
1 parent bb9dccf commit 19f9d0e

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-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: 18 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,21 @@ 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+
combineLatest([
38+
this.http.get('assets/map/world.json'),
39+
this.theme.getJsTheme(),
40+
])
41+
.pipe(takeWhile(() => this.alive))
42+
.subscribe(([map, config]: [any, any]) => {
43+
44+
this.es.registerMap('world', map);
3245

3346
const colors = config.variables;
3447
this.bubbleTheme = config.variables.bubbleMap;
@@ -527,7 +540,7 @@ export class BubbleMapComponent implements OnDestroy {
527540
}
528541

529542
ngOnDestroy() {
530-
this.themeSubscription.unsubscribe();
543+
this.alive = false;
531544
}
532545

533546
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)