We are shipping something overseas. More to come.
Created
September 8, 2014 03:35
-
-
Save darrenjaworski/d7c684e5e1698f57773a to your computer and use it in GitHub Desktop.
Orthographic
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"> | |
<body> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
( function map() { | |
var width = $(window).width() - 16, | |
height = width, | |
graticule = d3.geo.graticule(), | |
norman = [97.44, -35.22, 0]; | |
//35.2200° N, 97.4400° W norman | |
var projection = d3.geo.orthographic() | |
.scale(width / 2) | |
.clipAngle(90) | |
.translate([width / 2, height / 2]); | |
var canvas = d3.select("body").append("canvas") | |
.attr("width", width) | |
.attr("height", height); | |
var context = canvas.node().getContext("2d"); | |
var path = d3.geo.path() | |
.projection(projection) | |
.context(context); | |
d3.json("/d/4090846/world-110m.json", function(error, world) { | |
var countries = topojson.feature(world, world.objects.countries), | |
land = topojson.feature(world, world.objects.land), | |
grid = graticule(), | |
sphere = {type:"Sphere"}; | |
projection.rotate(norman); | |
context.beginPath(); | |
path(countries); | |
context.strokeStyle = "#fff"; | |
context.fillStyle = "#000"; | |
context.fill(); | |
context.stroke(); | |
context.beginPath(); | |
path(sphere); | |
context.strokeStyle = "#000"; | |
context.stroke(); | |
}); | |
}) (); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment