I'm trying to create a circle in my us map. But it's a little bit off. So I tried to translate it with the value from my us.json file. But it's still not correct.
async svgModifications(svgID) {
try {
const projection = d3.geoAlbersUsa();
const translate = this.us.transform.translate;
const scale = this.us.transform.scale;
const states = topojson.feature(this.us, this.us.objects.states);
const nation = topojson.feature(this.us, this.us.objects.nation);
const counties = topojson.feature(this.us, this.us.objects.counties);
const svg = d3.select("svg");
const path = svg.append("path");
//map
path.datum(states).attr("class", "states").attr("d", d3.geoPath());
//points
//points
//const x = this.myData[0].coordinates[0] * scale[0] + translate[0];
//const y = this.myData[0].coordinates[1] * scale[1] + translate[1];
svg.append("circle")
.data(this.myData)
.attr("r", 10)
.attr("cx", projection(this.myData[0].coordinates)[0])
.attr("cy", projection(this.myData[0].coordinates)[1])
.attr("transform", "translate(-56.77775821661018,12.469025989284091)");
} catch (e) {
console.log(e);
}
}
As you see i tried different approaches, but i don't quite understand, how i should do it.
Let me know if you need anything else
Edit: The US Json