"world-110m.json"을 사용하여지도를 만드는 데 성공했습니다. 그러나 나는 세계지도에 그 이름을 어떻게 넣어야할지 모르겠다.어떻게하면 세계지도에 국가 이름을 넣을 수 있습니까?
내 코드는 다음과 같습니다.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src = "https://d3js.org/d3.v3.min.js"></script>
<script src = "http://d3js.org/topojson.v1.min.js"></script>
</head>
<body>
<script>
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var projection = d3.geo.mercator()
.scale(130)
.translate([width/2, height/1.5]);
var path = d3.geo.path().projection(projection);
//Data loading
d3.json("world-110m.json", function(error, world) {
d3.tsv("world-110m-names.tsv", function(error, names) {
//I don't know what I can do??
})
svg.selectAll("path")
.data(topojson.feature(world, world.objects.countries).features)
.enter()
.append("path")
.attr("d", path)
});
</script>
</body>
</html>
두 파일의 공통점은 동일한 id 값을 갖는 것입니다. id 값을 사용하여이 작업을 수행해야한다고 생각하지만 어떻게해야할지 모르겠다. 모든
질문에 * 이미지 * 코드를 넣지 마십시오. tsv 파일의 몇 줄을 텍스트로 복사/붙여 넣기 만하면됩니다. –