Built with blockbuilder.org
Last active
July 4, 2017 18:31
-
-
Save infologie/0eaed7954c2b3eb9f9f3179288925bc1 to your computer and use it in GitHub Desktop.
demoD3
This file contains hidden or 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
license: mit |
This file contains hidden or 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> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/d3-geo-projection.v2.min.js"></script> | |
<style> | |
body { | |
margin: 0; | |
position:fixed; | |
top:0; | |
right:0; | |
bottom:0; | |
left:0; | |
} | |
path { | |
fill: none; | |
stroke: black; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
pyongyang = [125.75, 39.03] | |
washington = [-77.01, 38.89] | |
portee = d3.geoCircle().radius(6700 * 360 / ( 2 * Math.PI * 6371)) | |
.center(pyongyang)() | |
var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", 500) | |
// Projections : TwoPointEquidistant, Equirectangular, Orthographic, Larrivee, Armadillo | |
projection = d3.geoEquirectangular() | |
// .points(pyongyang,washington) | |
.rotate([180,0]) | |
path = d3.geoPath(projection) | |
svg.append("path") | |
.attr("d", path({ type: "Sphere"}) ) | |
d3.json("https://rawgit.com/visionscarto/some-geo-data/master/ne_110m_admin_0_countries/countries.geojson", | |
function(err, continents) { | |
svg.append("path") | |
.attr("d", path(continents) ) | |
.style("fill", "#ddd") | |
svg.append("path") | |
.attr("d", path(portee) ) | |
.style("fill", "rgba(255,0,0,0.5)") | |
svg.append("path") | |
.attr("d", path({type: "Point", coordinates: pyongyang}) ) | |
.style("fill", "red") | |
svg.append("path") | |
.attr("d", path({type: "Point", coordinates: washington}) ) | |
.style("fill", "red") | |
svg.append("path") | |
.attr("d", path({type: "LineString", coordinates: [pyongyang, washington]}) ) | |
.style("stroke", "red") | |
} | |
) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment