我使用geoJson
加载世界地图。我正在测试它是否有效,但我没有得到任何回报。我知道正在加载的文件是正确的。我期望的是获得返回的数据,再次验证一切正常。我没有任何错误。
从@ angular / core'导入{Component,OnInit,AfterViewInit}; 从*' d3';
导入*为d3@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent implements OnInit, AfterViewInit {
private svg;
private width;
private height;
private features;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
this.svg = d3.select("svg");
this.height = this.svg.attr("height");
this.width = this.svg.attr("width");
this.features = this.svg.append("g")
d3.json("/assets/files/views/maps/world.json", function(error, mapData) {
console.log(mapData.features);
});
}
}