I have topojson data to use with d3.js here: http://mazolosite.orionhub.org:8000/ZAF_adm3.json
I also created this fiddle to demo my issue, however it doesn't seem to load my topojson data: https://jsfiddle.net/gh583j5a/
This is my code that works locally with the issue of scaling and centering properly. The US topojson from the example seem to render fine with default projection.
I find myself struggling with scaling and projection given the lack of background in mapping API's.
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
debugger;
//var url = "https://gist.githubusercontent.com/mbostock/4090846/raw/d534aba169207548a8a3d670c9c2cc719ff05c47/us.json"
var url = "http://mazolosite.orionhub.org:8000/ZAF_adm3.json";
d3.json(url, function(error, topology) {
if (error) throw error;
//var featureCollection = topojson.feature(topology, topology.objects.counties);
var featureCollection = topojson.feature(topology, topology.objects.collection);
var bounds = d3.geo.bounds(featureCollection);
var centerX = d3.sum(bounds, function(d) {
return d[0];
}) / 2,
centerY = d3.sum(bounds, function(d) {
return d[1];
}) / 2;
var projection = d3.geo.mercator()
.scale(300)
.center([0,90]);//centerX, centerY
path.projection(projection);
svg.selectAll("path")
.data(featureCollection.features)
.enter().append("path")
.attr("d", path);
});
My problem is in understanding this part of d3.js (Scaling and center):
var projection = d3.geo.mercator() .scale(300) .center([0,90]);//centerX, centerY
Please help.