【发布时间】:2016-08-25 00:24:22
【问题描述】:
我有显示迪拜所有地区的巨大 geojson。这是一个示例:
{
"type":"FeatureCollection",
"totalFeatures":224,
"features":[
{
"type":"Feature",
"id":"Community.1",
"geometry":{
"type":"MultiPolygon",
"coordinates":[
[
[
[
55.16945847438926,
25.03005371689898
],
[
55.168575711653915,
25.03074785219016
],
[
55.169258376227525,
25.03150691074316
],
[
55.169931129543535,
25.032274981961805
],
]
]
]
},
"geometry_name":"the_geom",
"properties":{
"COMM_CODE":684,
"NAME_AR":"البرشاء الجنوب الخامسة",
"NAME_EN":"AL BARSHA SOUTH FIFTH",
"AREA_ID":442,
"SHAPE_AREA":2951425.95614,
"SHAPE_LEN":10871.405155
}
},
{
"type":"Feature",
"id":"Community.2",
"geometry":{
"type":"MultiPolygon",
"coordinates":[
[
[
[
55.34592943407097,
25.16925511754935
],
[
55.34604885385063,
25.17297434345408
],
[
55.34600905862783,
25.171854965446766
],
[
55.345979182892805,
25.170726559094064
],
[
55.34592943407097,
25.16925511754935
]
]
]
]
}
我在 d3 中有一个非常简单的代码,它解析 geojson 并将其显示在浏览器中。但是我看不到结果。
这是我的代码:
d3.json("dld.json", createMap);
function createMap(countries) {
var aProjection = d3.geo.mercator();
var geoPath = d3.geo.path().projection(aProjection);
d3.select("svg").selectAll("path").data(countries.features)
.enter()
.append("path")
.attr("d", geoPath)
.attr("class", "countries")
}
控制台中没有显示错误。 如果有人能指出我错在哪里,我将是最感激的:)
【问题讨论】:
-
标记无效。
<footer />元素必须在<body />中 -
@Andreas 我修好了,但问题仍然存在
-
嗨。为什么不删除除 2 个对象之外的所有数据。然后重试,并发布较短的代码。
-
@BrianB 编辑了我的问题。
标签: javascript d3.js geojson