Using turf.js distance to figure out how far all the maptimes are from MaptimeSF.
Last active
August 29, 2015 14:03
-
-
Save mpmckenna8/3975be6a974ea7c0bc8d to your computer and use it in GitHub Desktop.
Maptimes distances from MaptimeSF w/ turf.js
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
</style> | |
<body> | |
<h3>Distances away from</h3> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<script src="/mpmckenna8/raw/def3735b8e1eef5128a7/turf.min.js" charset="utf-8"></script> | |
<script> | |
d3.json('maptimes.geojson', function(maptimes){ | |
console.log(maptimes.features[2]) | |
var info = maptimes.features; | |
var bods = d3.select('body').append('div').attr('class', 'dists') | |
//.data(info).enter().append('tr'); | |
bods.selectAll('.mappers') | |
.data(info) | |
.enter() | |
.append('html:p') | |
.text(function(d){ | |
console.log(d); | |
var blah = d.properties.title; | |
return blah | |
}) | |
.attr('class','mappers') | |
d3.selectAll('.mappers') | |
.append('html:div') | |
.text(function(d,i) | |
{ | |
console.log(info[i] + i) | |
if(i > 0){ | |
return turf.distance(info[0],d,'miles') + ' miles' | |
} | |
}) | |
}) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment