All examples By author By category About

mpmckenna8

Turf.js distance first try w/ d3 map topojson data

First attempt at using turf.js client side. Not really terribly useful as is but I had some ideas for setting up the distance information better (w/out commas at the beginning of lines) and with hover events causing their corresponding icons on the map to so something or be highlighted with a like color. For no commas I could have done a good old data or datum enter deal.

This file uses the turf.min.js file so I could have gotten any functionality out of turf I wanted in this page though I only used a one small part of it. I guess the big thing I didn't see straight up in the documentation for turf.js was how to call one of the functions from it's library of them.

It was really quite easy you just do turf.thefunction(args) as in:

turf.distance(point1,point2,unit)

It's so easy and I should start in on the wiki explaining how to do this amazingness client side. With d3 it was cool to get the distances in radians but this is quick nice and easy and returns something I have some conception of rather than radians. I was a little worried that my distances weren't correct after checking the first few google results for a distance but a viable looking source matched up close to exactly w/ my results. http://dateandtime.info/distance.php?id1=3469058&id2=3390760 It's also the first one I found which explained at least a little bit about the calculations so I trust it more than the other ones which I have no idea how the distance was calculated.

Now I want to learn how to use turf.js for something actually useful maybe and you should too and share it with me.