I have been pounding my head for several hours to how does my map shows super small in D3.
I've tried adjusting the scale but it doesn't seam to project correctly.
Here's my code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Manda</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<style>
.states :hover {
fill: red;
}
.state-borders {
fill: none;
stroke: #fff;
stroke-width: 0.5px;
stroke-linejoin: round;
stroke-linecap: round;
pointer-events: none;
}
svg {
background: rgb(201, 197, 197);
}
</style>
</head>
<body>
<svg></svg>
</body>
<script>
var w = 960,
h = 600;
var svg = d3.select("svg");
svg.attr("width", w).attr("height", h);
var projection = d3
.geoAlbers()
.scale(200)
.translate([w / 2, h / 2]);
var path = d3.geoPath().projection(projection);
d3.queue()
.defer(d3.json, "NCR/Mandaluyong/MandaTopo.json")
.await(ready);
function ready(err, data) {
if (err) return console.log(err);
var brgys = topojson.feature(data, data.objects.Mandaluyong).features;
svg
.selectAll(".brgy")
.data(brgys)
.enter()
.append("path")
.attr("class", "brgy")
.attr("d", path)
.attr("stroke", "black");
}
</script>
</html>
I added an stroke to emphasize the map.
Here's the MandaTopo.json. https://raw.githubusercontent.com/popoy2k/MandaLightMap/master/NCR/Mandaluyong/MandaTopo.json
Here's what i see in the svg Click me