Skip to content

Instantly share code, notes, and snippets.

@LuisSevillano
Last active October 19, 2019 11:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuisSevillano/1bc456a5e0716356f141e3db68651162 to your computer and use it in GitHub Desktop.
Save LuisSevillano/1bc456a5e0716356f141e3db68651162 to your computer and use it in GitHub Desktop.
New composite border in es-atlas
border:none
height:696
license:MIT

The new version of es-atlas will incorporate the option to preproject the TopoJSON's. With this option a new object is included within the TopoJSON that lets you to draw a composition border for the Canary Islands as usual in this kind of maps.

<!DOCTYPE html>
<script src="https://unpkg.com/d3-composite-projections"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://d3js.org/topojson.v3.min.js"></script>
<svg></svg>
<script>
const margin = { top: 20, right: 20, bottom: 20, left: 20 },
width = window.innerWidth - margin.left - margin.right,
height = width * 0.8 - margin.top - margin.bottom;
const svg = d3
.select("svg")
.attr("width", width)
.attr("height", height);
d3.json("municipalities.json")
.then(es => {
const projection = d3
.geoIdentity()
.reflectY(false)
.fitSize(
[width - margin.left - margin.right, height],
topojson.feature(es, es.objects.border)
);
const path = d3.geoPath(projection);
svg
.datum(topojson.feature(es, es.objects.municipalities))
.append("path")
.attr("fill", "none")
.attr("stroke", "black")
.attr("d", path);
svg
.append("path")
.datum(topojson.feature(es, es.objects.composite_border))
.attr("d", d => path(d))
.attr("fill", "none")
.attr("stroke", "black");
})
.catch(err => console.warn(err));
</script>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment