Hugolpz
Hugolpz

Reputation: 18258

Topojson v.0 to v.1 migration difficulties

I used recommendations by Mike Bostock on Topojson: list of differences between v0 and v1? to migrate my code from v0 to v1.

No other changes made.

My data is the same final_adms_France.json file.

What is the issue ? How to make it work ?


Comment: Seems I got an issue with :

 .attr("transform", function(d) { return "translate(" + projection(d.coordinates) + ")"; })

out of :

// Positioning: place-label
    svg.selectAll(".place-label")
        .data(topojson.object(fra, fra.objects.places).geometries)
      .enter().append("text")
        .attr("class", "place-label")
        .attr("transform", function(d) { return "translate(" + projection(d.coordinates) + ")"; })
        .attr("dy", ".35em")
        .text(function(d) { if (d.properties.name!=="Paris"&&d.properties.name!=="Bremen"){return d.properties.name;} })
        .attr("x", function(d) { return d.coordinates[0] > -1 ? 6 : -6; })
        .style("text-anchor", function(d) { return d.coordinates[0] > -1 ? "start" : "end"; });

Upvotes: 2

Views: 82

Answers (1)

Alex Filipovici
Alex Filipovici

Reputation: 32561

You should use d.geometry.coordinates instead of d.coordinates.

Upvotes: 1

Related Questions