我正在开展一个团队项目,d3地图正在其他人的计算机上正确呈现,但我的。这是我的地图代码段:
var g = svg.append("g");
// as written, the function(error, us) callback won't fire until the d3.json finishes
d3.json("json/usa_map.json", function(error, us) {
g.selectAll("path")
.data(us.features)
.enter()
它在us.features
上中断,它表示没有方法"功能"在未定义。这是我的geoJson片段:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "GEO_ID": "0400000US04", "STATE": "04", "NAME": "Arizona", "LSAD": "", "CENSUSAREA": 113594.084000 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -112.538593, 37.000674 ], [ -112.534545, 37.000684 ], [ -112.368946, 37.001125 ], [ -112.357690, 37.001025 ], [ -111.412784, 37.001478 ], [ -111.405869, 37.001481 ], [ -111.405517, 37.001497 ], [ -111.189888, 37.000959 ], ...
所以你可以看到...我有一个名为" features"的属性。
另外,我的地图适用于Firefox,但不适用于Chrome。知道发生了什么事吗?
在回调中传递的错误消息:
SyntaxError:意外的令牌{{stack:(...),消息:"意外 令牌{"}