Scott Murray
unread,May 5, 2012, 12:34:30 PM5/5/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to d3...@googlegroups.com
Projections are just configurable functions. First, you're using the projection "xym" to project your GeoJSON features (I assume).
To place points on the map, using the same projection, you'll need their latitude/longitude values. Just feed those to the xym projection function, as a two-value array, which could look like this:
projection([d.lon, d.lat]);
Note that longitude goes first!
That will return another two-value array, which are x/y screen coordinates. So you just need to get at those numbers in the array in whatever way works best for you, such as:
var coords = projection([d.lon, d.lat]);
var x = coords[0];
var y = coords[1];
Or, to integrate it into your code below, you could change the cx/cy lines to read:
.attr("cy", function(d) { return Vis.projection([d.lon, d.lat])[0]; })
.attr("cx", function(d) { return Vis.projection([d.lon, d.lat])[1]; })
Good luck!