I'm trying to plot a bunch of points on a map of the US in d3 and the plot locations are just a bit off from where they should be based on lat-long.
I'm using https://d3js.org/us-10m.v1.json to draw the state borders, which I understand (from this https://github.com/topojson/us-atlas#us/10m.json) to be based on d3's geoAlbers projection. So I'm using d3's geoAlbers projection to plot the lat-longs of the points, but they're not plotting in the correct places (see jsfiddle, with Boston plotting in upstate NY). I suspect the problem has something to do with the projections, but I can't put my finger on it.
JSFiddle: https://jsfiddle.net/Robmattles/n1cdxkna/12/
var width = 960; var height = 600;
var projection = d3.geoAlbersUsa();
var path = d3.geoPath();
var svg = d3.select("#map").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("https://d3js.org/us-10m.v1.json",function(error,us) {
states = topojson.feature(us, us.objects.states).features
svg.append("g")
.attr("class", "states")
.selectAll("path")
.data(states)
.enter()
.append("path")
.attr("d", path)
.style('fill','yellow')
svg.append("path")
.datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; }))
.attr("class", "mesh")
.attr("d", path);
svg.append("circle")
.attr("cx", function() { return projection([-71.0589,42.3601])[0];})
.attr("cy", function() { return projection([-71.0589,42.3601])[1];})
.attr("r",6)
.attr("class","source-port");
svg.append("text")
.attr("x", function() { return projection([-71.0589,42.3601])[0] + 5;})
.attr("y", function() { return projection([-71.0589,42.3601])[1] + 0;})
.text("Boston");
});