1
我有一個部門(紅線)和城市(灰色線)部門。我希望我的地圖隱藏城市的線路,以便稍後使用按鈕顯示或消失這些線條。不透明度:0不起作用。我想實現的另一件事是繪製紅色部門,這包括當前未繪製的外部線條,我的意思是輪廓圖的線條。在地圖中使用d3.js隱藏城市的線路
d3.json("https://cdn.rawgit.com/finiterank/mapa-colombia-js/9ae3e4e6/colombia-municipios.json", function(error, co) {
var subunits = topojson.feature(co, co.objects.mpios);
var projection = d3.geo.mercator()
.scale(1000)
.translate([width/2, height/2])
.center([-61,43])
.rotate([2,3,2]);
var path = d3.geo.path()
.projection(projection);
svg.append("path")
.datum(subunits)
.attr("d", path);
svg.selectAll(".mpio")
.data(topojson.feature(co, co.objects.mpios).features)
.enter().append("path")
.attr("class", function(d) { return "mpio " + "_" + d.id; })
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(co, co.objects.mpios, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "mpio-borde");
svg.append("path")
.datum(topojson.mesh(co, co.objects.depts, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "depto-borde");
片段有錯誤 – Weedoze
謝謝,是外部庫的https://而不是http://(猜我應該經常檢查幾個瀏覽器) –