I am trying to plot a map using a JSON file, I have tried all the always at my end but all the paths(regions on the map that should be different sizes and spread across the map) come up the same size(height and width) and in the same x and y coordinates. You would understand better when you run the code and inspect the SVG element in the browser. I am mentioning my code and the JSON file.
//Width and height
var w = 800;
var h = 800;
//Define map projection
var projection = d3.geoAlbersUsa();
// translate the map to w/2 and h/2 and scale it to 500
// to see the map properly
//Define path generator
var path = d3.geoPath()
.projection(projection);
//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
//Load in GeoJSON data
d3.json("https://api.jsonbin.io/b/5f955d1bbd69750f00c34c5e").then(function(json) {
console.log(json.features);
json.features = json.features.map(function(feature) {
return turf.rewind(feature, {
reverse: true
});
})
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path);
// Try coloring the elements using fill steelblue
});
<script type="text/javascript" src="https://d3js.org/d3.v5.min.js"></script>
<script src='https://unpkg.com/@turf/turf/turf.min.js'></script>