1
我试图绘制d3.js地图,但我不断收到Problem parsing d="MNaN,NaN"
d3.js麻烦解析“MNaN,NAN”
<!-- language: lang-js -->
var width=960, height=500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var q = 0;
var sc = 3000;
var d3line2 = d3.svg.line()
.x(function(d){q= 0.95105*sc*(d[0]+66.4262); return q;})
.y(function(d){q= sc*(-1*d[1]+ 18.2336); return q;})
.interpolate("linear");
d3.json("/prCounties.json", function(d){
for(var k = 0; k < d.features[0].length; k++){
svg.append("path")
.attr("d", d3line2(d.features[0][k].geometry.coordinates))
.attr("class", "stroke");
}
});
这里是GeoJSON的文件 - 它应该是相同的,以什么对GitHub。
{
"type": "FeatureCollection",
"properties": {"kind": "state", "state": "PR"},
"features": [[
{"geometry": {"type": "MultiPolygon", "coordinates": [[[[-66.7222, 18.2198], [-66.6838, 18.2034], [-66.6729, 18.1541], [-66.6948, 18.1322], [-66.7167, 18.1322], [-66.7331, 18.1103], [-66.7715, 18.1377], [-66.7989, 18.1322], [-66.8262, 18.1705], [-66.8153, 18.2308], [-66.7824, 18.2527]]]]},
"type": "Feature", "properties": {"kind": "county", "name": "Adjuntas", "state": "PR"}
}
JsFiddle。这是一个很好的电话。它出来了。 [图](https://a248.e.akamai.net/camo.github.com/521b09a4A0d52539fd2b83060503d96bada85d277/687474703a2f2f646c2e64726f70626f782e636f6d2f752f31373934393130302f70722e706e67) – 2013-02-28 07:07:08