javascript - D3js: how to get Lat/Log geocoordinates from mouse click? -


using d3js code , projected topojson data on map dataviz of any projection, how can geocoordinates ? such:

var svg = d3.select("#viz").append("svg:svg")  .attr("width", 320)  .attr("height", 200)  .on("mousedown", mousedown)  .on("click", mouselocation); 

how geocordinates click on d3js map visualisation ?

links demos welcome.


edit: list of relevant demos :

use d3.mouse pixel coordinates, , use projection (d3.geo.azimuthal, here) invert x , y longitude , latitude. example:

d3.select("svg").on("mousedown.log", function() {   console.log(projection.invert(d3.mouse(this))); }); 

if want support clicking on background of svg, may want invisible rect pointer-events: all. (also note: older versions of d3 used d3.svg.mouse rather d3.mouse.)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -