1
詳細信息:
我有以下設置。生成的自定義topjson文件,只是想顯示在我的網頁。我可以在控制檯中看到,創建並正確加載數據,但由於某些原因,d3不會顯示任何路徑元素,也不會顯示任何內容。D3中的GeoJSON:路徑未綁定到數據
的Javascript
var width = 960;
var height = 500;
var svg = d3.select('body').append('svg')
.attr('width', width)
.attr('height', height);
var projection = d3.geo.albersUsa()
.scale(1000)
.translate([width/2, height/2]);
var path = d3.geo.path()
.projection(projection);
d3.json('http://localhost.com/calgary.json', function(error, calgary) {
svg.append('path')
.datum(topojson.feature(calgary))
.attr('d', path)
.attr('fill','red');
});
定製Topojson文件:
依賴於:
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
你在控制檯上有任何錯誤嗎? – elias