Created
April 19, 2015 02:54
-
-
Save bhousel/29571cc966757aed4aec to your computer and use it in GitHub Desktop.
Show lat/lng of mouse cursor in #iD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am new to the D3 Frame work. Can U please suggest me where to include this code in my iD.js .