Skip to content

Commit

Permalink
fix(map): get the bubble map back (thanks to @SUlbrichA) (#1655)
Browse files Browse the repository at this point in the history
Closes #1576
  • Loading branch information
nnixaa committed Apr 26, 2018
1 parent bb9dccf commit 19f9d0e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"../node_modules/tinymce/plugins/paste/plugin.min.js",
"../node_modules/tinymce/plugins/table/plugin.min.js",
"../node_modules/echarts/dist/echarts.min.js",
"../node_modules/echarts/dist/extension/bmap.min.js",
"../node_modules/chart.js/dist/Chart.min.js"
],
"environmentSource": "environments/environment.ts",
Expand Down
23 changes: 18 additions & 5 deletions src/app/pages/maps/bubble/bubble-map.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Component, OnDestroy } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { combineLatest } from 'rxjs/observable/combineLatest';
import { takeWhile } from 'rxjs/operators/takeWhile';
import { NgxEchartsService } from 'ngx-echarts';
import { NbThemeService } from '@nebular/theme';

@Component({
Expand All @@ -23,12 +27,21 @@ export class BubbleMapComponent implements OnDestroy {

bubbleTheme: any;
geoColors: any[];
themeSubscription: any;

constructor(private theme: NbThemeService) {
private alive = true;

this.themeSubscription = this.theme.getJsTheme()
.subscribe(config => {
constructor(private theme: NbThemeService,
private http: HttpClient,
private es: NgxEchartsService) {

combineLatest([
this.http.get('assets/map/world.json'),
this.theme.getJsTheme(),
])
.pipe(takeWhile(() => this.alive))
.subscribe(([map, config]: [any, any]) => {

this.es.registerMap('world', map);

const colors = config.variables;
this.bubbleTheme = config.variables.bubbleMap;
Expand Down Expand Up @@ -527,7 +540,7 @@ export class BubbleMapComponent implements OnDestroy {
}

ngOnDestroy() {
this.themeSubscription.unsubscribe();
this.alive = false;
}

private getRandomGeoColor() {
Expand Down
1 change: 1 addition & 0 deletions src/assets/map/world.json

Large diffs are not rendered by default.

0 comments on commit 19f9d0e

Please sign in to comment.