I want to create a very simple drilldown map with Highcharts / Highmaps, with my geojsons (not those from Highcharts).
They look like this (as exported by a software) :
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"Id": "Region1",
"Name": "My First Region" },
"geometry": {
"type": "MultiPolygon",
"coordinates": [ [ [ [ 830.49832547647298, 9313.4877617806696 ], ...
Here is my code so far (based on a mashup of various tutorials and trial-and-error...) :
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { forkJoin } from 'rxjs';
import { Highcharts, MapChart } from 'angular-highcharts';
@Component({
selector: 'app-demo-map-drilldown',
template: '<div [chart]="chart" class="container" id="container"></div>',
styleUrls: ['./demo-map-drilldown.component.css']
})
export class DemoMapDrilldownComponent implements OnInit {
constructor(private httpClient: HttpClient) { }
ngOnInit() {
let geoJsonList = [];
["Country", "Region1", "Region2", "Region3"].forEach((name) => {
geoJsonList.push(this.httpClient.get("assets/" + name + ".geojson"));
});
forkJoin(geoJsonList).subscribe(geoJsons => {
geoJsons[0]["features"].map((element, i) => {
element.drilldown = element.properties['Id']; // Id looks like "RegionX" in my files
element.value = i;
});
this.chart = new MapChart({
chart: {
map: geoJsons[0]
},
title: {
text: 'GeoJSON in Highmaps'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
tickPixelInterval: 100
},
series: [{
data: [
["Region1", "Region1", 44],
["Region2", "Region2", 49],
["Region3", "Region3", 53]
],
keys: ['Name', 'drilldown', 'value'],
joinBy: 'Name',
name: 'Random data',
states: {
hover: {
color: '#a4edba'
}
},
dataLabels: {
enabled: true,
format: '{point.properties.Name}'
}
}],
drilldown: {
series: [{
data: [
["CityA", 1],
["CityB", 5]
],
id: 'Region1'
}, {
data: [
["CityC", 3],
["CityD", 4]
],
id: 'Region2'
}, {
data: [
["CityE", 0],
["CityF", 2]
],
id: 'Region3'
}]
}
});
});
}
}
The problem is, I don't know how to load a different map during the drilldown. As of now, if I click on a region, the drilldown animation plays but loads the same map (well, with different data values).
Can someone help me ? Thanks !
PS : I don't know how to provide a working sample of this kind of projet, sorry...