Skip to content

Instantly share code, notes, and snippets.

@bhousel
Created April 19, 2015 02:54
Show Gist options
  • Save bhousel/29571cc966757aed4aec to your computer and use it in GitHub Desktop.
Save bhousel/29571cc966757aed4aec to your computer and use it in GitHub Desktop.
Show lat/lng of mouse cursor in #iD
id.surface().on('mousemove.custom', function() {
function wrap(x, min, max) { var d = max - min; return ((x - min) % d + d) % d + min; }
var ll = d3.select('#content')
.selectAll('#latLng')
.data([0]);
ll.enter()
.append('div')
.attr('id', 'latLng')
.attr('class', 'fillD')
.attr('style', 'position:absolute; top:70px; right:80px; padding:5px; color: #ccc');
ll
.text(function() {
var coord = id.map().mouseCoordinates();
return wrap(coord[1], -90, 90).toFixed(5) + ', ' + wrap(coord[0], -180, 180).toFixed(5);
});
});
@mobina
Copy link

mobina commented Apr 20, 2015

I am new to the D3 Frame work. Can U please suggest me where to include this code in my iD.js .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment