Javascript 为什么我的d3地图看起来很奇怪?

Javascript 为什么我的d3地图看起来很奇怪?,javascript,d3.js,geojson,topojson,Javascript,D3.js,Geojson,Topojson,我正试图投射一张美国的d3地图。出于某种原因,它看起来是这样的: 我使用mapshaper.org创建了一个topojson。我看了一下这个链接: 但这并不是很有帮助。这是我的密码: <html lang="en"> <head> <meta charset="utf-8"> <title>D3 Test</title> </head> <body> <script src="htt

我正试图投射一张美国的d3地图。出于某种原因,它看起来是这样的:

我使用mapshaper.org创建了一个topojson。我看了一下这个链接:

但这并不是很有帮助。这是我的密码:

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>D3 Test</title>
</head>
<body>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="http://d3js.org/queue.v1.min.js"></script>
    <script src="http://d3js.org/topojson.v1.min.js"></script>
    <script type="text/javascript">
            var width = 960,
                height = 500;

            var projection = d3.geo.albersUsa()
                .scale(1000)
                .translate([width / 2, height / 2]);

            var path = d3.geo.path()
                .projection(projection);

            var svg = d3.select("body").append("svg")
                .attr("width", width)
                .attr("height", height);

            d3.json("states.json", function(error, us) {

              svg.insert("path", ".graticule")
                  .datum(topojson.mesh(us, us.objects.counties, function(a, b) { return a !== b && !(a.id / 1000 ^ b.id / 1000); }))
                  .attr("class", "county-boundary")
                  .attr("d", path);

              svg.insert("path", ".graticule")
                  .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; }))
                  .attr("class", "state-boundary")
                  .attr("d", path);
            });

            d3.select(self.frameElement).style("height", height + "px");                
    </script>
</body>
你能帮我吗


谢谢

设置填充:无;笔划:CSS中的路径元素为黑色。@Larskothoff,这在某种程度上修复了它。然而,我不再了解这个国家的概况:你知道什么吗?谢谢你的帮助!这些可能在数据中作为一个单独的对象-us.objects.country?可能就像Lars说的,或者你在CSS中有一些特殊的边界,这也是可能的。您是否使用了现有的示例,然后请显示您的代码。谢谢大家!我添加了以下代码:svg.insertpath、.graticule.datumtopojson.featureus、us.objects.land.attrclass、land.attrd、path;它增加了国家边界。