Skip to content

Instantly share code, notes, and snippets.

@apbryant
Last active October 15, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apbryant/f0e68896cc09aaef559cdae1f3986aac to your computer and use it in GitHub Desktop.
Save apbryant/f0e68896cc09aaef559cdae1f3986aac to your computer and use it in GitHub Desktop.
Dos Chiles
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dos Chiles</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<script type="text/javascript">
// Your beautiful D3 code will go here
var h = 1000;
var w = 1000;
var projection = d3.geoMercator().translate([w / 2, -20])
.scale(300);
var projection2 = d3.geoMercator().translate([w * .5 , h *.5 ])
.scale(300).rotate([0, 0, 180]);
var path2 = d3.geoPath()
.projection(projection2);
var path = d3.geoPath()
.projection(projection);
var svg = d3.select('body')
.append('svg')
.attr('height', h)
.attr('width', w);
var gMap = svg.append('g').attr('id', 'map');
var gPoint = svg.append('g');
// data from: https://geojson-maps.ash.ms/
d3.json('chile.json').then(function(data){
gMap.selectAll('path')
.data(data.features)
.enter()
.append('path')
.attr('d', path)
.attr('fill', '#E8D7F1')
.attr('stroke', '#D3BCCC');
});
// data from: https://bit.ly/2NOo4H9
d3.json('chile_regions.json').then(function(data){
gMap.selectAll('path')
.data(data.features)
.enter()
.append('path')
.attr('d', path2)
.attr('fill', '#E8D7F1')
.attr('stroke', '#D3BCCC');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment