小编Ser*_*nov的帖子

D3.js 绘制 geojson 不正确

我正在尝试可视化俄罗斯地区。我从拿到的数据在这里,验证在这里,一切都很好-图片

但是当我尝试绘制它时,我只收到一个大的黑色矩形。

var width = 700, height = 400;

var svg = d3.select(".graph").append("svg")
        .attr("viewBox", "0 0 " + (width) + " " + (height))
        .style("max-width", "700px")
        .style("margin", "10px auto");


d3.json("83.json", function (error, mapData) {
    var features = mapData.features;

    var path = d3.geoPath().projection(d3.geoMercator());

    svg.append("g")
            .attr("class", "region")
            .selectAll("path")
            .data(features)
            .enter()
            .append("path")
            .attr("d", path)
});
Run Code Online (Sandbox Code Playgroud)

示例 - http://ustnv.ru/d3/index.html Geojson 文件 - http://ustnv.ru/d3/83.json

javascript openstreetmap geojson d3.js

4
推荐指数
1
解决办法
1106
查看次数

标签 统计

d3.js ×1

geojson ×1

javascript ×1

openstreetmap ×1