-1

我有一个函数drawCountry,它试图根据点击的国家读取一个json文件:

    d3.json("../json/"+d.id.toLowerCase()+"/regions.json", function(error, json) {
        if (error) {
            return console.warn(error);
            self.drawMap();
        }
        else {
        self.regionsGroup.selectAll("path")
        .data(json.features)
        .enter().append("path")
        .attr("d", self.projection)
        .attr("id", function(d) {
            return d.properties.name;
        })
        .classed("country", true)
        .attr("class", "country")
        .on("mouseover", function(d) {
            d3.select(this)
            .style("fill", "#6C0")
            .append("svg:title")
            .text(d.properties.name);
        })
        .on("mouseout", function(d) {
            d3.select(this)
            .style("fill", "#000000");
        })
        .on("click", function(d) {
            console.log('clicked on country')
        });
        }
    });

我看不到如何加载 self.drawMap(); 什么时候有错误?

4

1 回答 1

0
return console.warn(error);  <-- exits out of the function
self.drawMap();  <--never gets called because of the return

换行

self.drawMap(); 
return console.warn(error);  
于 2013-02-01T14:06:46.390 回答