我目前在尝试在 d3 世界地图上显示国家/地区名称时遇到问题。
这是显示国家/地区名称的传单示例的图像。这将是我想添加到我的 d3 版本中的内容。如果可能的话,只需国家名称。如果没有,我总是可以走传单路线,但我想我会先在 d3 尝试。
这是d3版本
这是我目前绘制地图的方式
// reference to actual element d3 selects
this.svg = d3.select(this.mapContainer.nativeElement)
.append('svg')
.attr('width', this.width)
.attr('height', this.height)
.call(zoom)
.append('g')
.attr('class', 'map');
this.projection = d3.geoMercator()
.scale(225)
.translate([this.width / 2, this.height / 1.5]);
const path = d3.geoPath().projection(this.projection);
let g = this.svg.append('g');
// if unknown is not in the filter set remove it from the json
const filteredWorldMapJson = this.worldMapJson.features;
// features are a list of countries
// ex: { type: 'Feature', properties: { name: …Run Code Online (Sandbox Code Playgroud)