I am trying to return [x,y] geo coordinates on a geo tile map. If you look in the console log on the following jsfiddle you will see they are coming out wrong. I am using the projection.invert() function, which I assume works backwards from the pixels to get back to the geo coordinates ... what am I doing wrong?
This is the bit of code that tries to seize the coordinates:
function mousemoved() {
console.log(formatLocation(projection.invert(d3.mouse(this)), d3.zoomTransform(this).k));
}
function formatLocation(p, k) {
var format = d3.format("." + Math.floor(Math.log(k) / 2 - 2) + "f");
return (p[1] < 0 ? format(-p[1]) + "°S" : format(p[1]) + "°N") + " "
+ (p[0] < 0 ? format(-p[0]) + "°W" : format(p[0]) + "°E");
}