无法使用d3.js增加地图(绘图)的大小

时间:2019-06-28 18:51:33

标签: javascript d3.js data-visualization geojson topojson

我正在尝试使用d3js和topojson显示巴基斯坦地图,但地图的尺寸​​很小,因此无法增加其尺寸。

topojson的网址:https://raw.githubusercontent.com/deldersveld/topojson/master/countries/pakistan/pakistan-provinces.json

我尝试使用音阶并进行翻译,但这没有用。

<meta charset="utf-8">

<style>

path {
  fill: none;
  stroke: #000;
  stroke-width: .5px;
}

</style>

<body>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>

    <link href="http://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">


<script>

var width = 960,
    height = 480;

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

var projection = d3.geo.equirectangular()
    .scale(153)

    .precision(.1);

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

d3.json("pak_map.json", function(error, topology) {
    if (error) throw error;

    svg.append("path")
      .datum(topojson.feature(topology, topology.objects.PAK_adm1))
      .attr("d", path)
      .attr("class", "land-boundary");
});

</script>

</body>
</html>

0 个答案:

没有答案