1

The topojson file with my code shows only one propriety with one path,my topojson file looks like the sample . what I am doing wrong ? I dont know if the problem with the topojson or the code as this my first project

the output show only one polygon where it must shows five

my code:

createMap("QasabatAmmanTempWithoutMadina.json");

function createMap(topojsonFile) {
    d3.json(topojsonFile, function(error, tj) {
    svg.selectAll("path").remove();

        //console.log(key in tj.objects);

        for(key in tj.objects) { features = tj.objects[key];console.log(tj.objects[key]); }
        console.log(features);
        var estados = topojson.feature(tj, features);
            console.log(estados)
        var b = path.bounds(estados);
        var s = 0.95/ Math.max((b[1][0] - b[0][0]) / width, (b[1][1] - b[0][1]) / height);
        var t = [(width - s * (b[1][0] + b[0][0])) / 2, (height - s * (b[1][1] + b[0][1])) / 2];

        projection
            .scale(s)
            .translate(t);

        g.selectAll("path")
            .data(topojson.feature(tj, features).features)
            .enter().append("path")
            .attr("d", path)
            .attr("class", "feature");
            //.on("click", click);

        g.append("path")
            .datum(topojson.mesh(tj, features, function(a,b) { return a !== b; }))
            .attr("class", "mesh")
            .attr("d", path);
    });
}

sample of topjson file:

{"type":"Topology","arcs":[[[5629,4900],[26,-20],[21,-38],[-19,-32],[-11,-49],[-40,-82],[-44,-37],[-69,-61],[-53,-23],[-57,-10],[-74,3],[78,32],[78,30],[66,20],[84,6],[39,-14],[31,-58],[43,-68],[44,-36],[33,-30],[43,-37],[52,-47],[57,-40],[43,-36],[47,-16],[47,-18],[68,-6],[72,-6],[65,-4],[74,0]],[[4419,5688],[-31,4],[-113,106],[-12,29],[-20,25],[-27,16],[-38,5],[-171,-8],[-232,76],[-31,-61],[80,-4],[164,-72],[17,1],[180,-67],[27,-23],[34,-17],[36,-32],[24,-34],[9,-38],[4,-29],[6,-29],[6,-31],[-8,-18],[15,-44],[-8,5],[-32,16],[-14,7],[-41,-3],[-36,-13],[-24,-10],[-19,-11],[-24,-3],[-42,14],[-34,10],[-39,10],[-40,20],[-21,18],[-15,19],[-12,27],[-10,17],[-16,18],[-24,5],[-25,-1],[-22,-2],[-24,-18],[20,5],[28,-10],[19,-11],[15,-14],[11,-14],[-5,-20],[-53,32],[-98,-36],[-245,72],[-43,36],[-94,62],[-157,28],[-153,54],[-100,83],[-35,4],[-86,-21],[-63,7],[-55,1],[-98,4],[-101,24],[-72,28],[-36,11],[-28,11],[-15,3],[-98,-6],[-66,1],[-29,9],[-58,26],[-58,37],[-74,65],[-46,62],[-45,84],[-47,136],[-30,135],[-6,69],[6,61],[24,138],[64,122],[77,111],[159,158],[258,228],[68,59],[98,62],[61,25],[80,11],[129,-8],[47,10],[58,23],[99,47],[51,29],[85,58],[95,62],[42,21],[103,39],[193,62],[-26,-196],[3,-134],[0,-57],[5,-114],[-4,-137],[-12,-58],[0,-43],[34,-103],[53,-144],[57,-74],[59,-52],[163,-104],[39,-47],[69,-67],[35,-54],[7,-41],[-32,-103],[1,-20],[35,-121],[16,-29],[87,-83],[24,-15],[26,-2],[30,15],[13,-37],[39,-38],[4,-23],[49,-128],[-3,-30],[19,-46],[17,-70]]],"transform":{"scale":[0.000012395198638604345,0.000011753131339408293],"translate":[35.86398878517448,31.89607962076447]},"objects":{"Zahran_Trusted":{"type":"GeometryCollection","geometries":[{"arcs":[[0]],"type":"Polygon","properties":{"Level":3,"Name_1":"Amman","Name_2":"Qasabat

Amman","Name_3":"Zahran"}}]},"YarmukAmman_Trusted":{"type":"GeometryCollection","geometries":[{"arcs":[[1]],"type":"Polygon","properties":{"Level":3,"Name_1":"Amman","Name_2":"Qasabat Amman","Name_3":"Yarmuk Amman"}}]},"RasAlEin_Trusted":{"type":"GeometryCollection","geometries":[{"arcs":[[2]],"type":"Polygon","properties":{"Name_1":"Amman","Name_2":"Qasabat Amman","Name_3":"Ras Al Ein"}}]},"BadrAmman_Trusted":{"type":"GeometryCollection","geometries":[{"arcs":[[3]],"type":"Polygon","properties":{"Level":3,"Name_1":"Amman","Name_2":"Qasabat Amman","Name_3":"Badr Amman"}}]},"Abdali_Trusted":{"type":"GeometryCollection","geometries":[{"arcs":[[4]],"type":"Polygon","properties":{"Level":3,"Name_1":"Amman","Name_2":"Qasabat Amman","Name_3":"Abdali"}}]}}}]

]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.