Skip to content

Instantly share code, notes, and snippets.

@Samagoue
Last active January 12, 2019 06:31
Show Gist options
  • Save Samagoue/ccddb020746f8d5fb4c7bec2aedba8e7 to your computer and use it in GitHub Desktop.
Save Samagoue/ccddb020746f8d5fb4c7bec2aedba8e7 to your computer and use it in GitHub Desktop.
COTE D'IVOIRE
license: gpl-3.0
height: 600
border: no
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<style>
.districts :hover {
fill: red;
}
.districts-borders {
fill: none;
stroke: #fff;
stroke-width: 1px;
stroke-linejoin: round;
stroke-linecap: round;
pointer-events: none;
}
.sousprefecture :hover {
fill: yellow;
}
.sousprefectures-borders {
fill: none;
stroke: #fff;
stroke-width: 0.5px;
stroke-linejoin: round;
stroke-linecap: round;
pointer-events: none;
}
</style>
<svg width="960" height="600"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<script>
var width = 1000,
height = 800;
var svg = d3.select("svg");
var projection = d3.geoMercator()
.scale(2000)
.translate([width / 2, height / 2]);
var path = d3.geoPath().projection(projection);
d3.json("gadm36_CIV.json", function(error, civ) {
if (error) throw error;
svg.append("g")
.attr("class", "districts")
.selectAll("path")
.data(topojson.feature(civ, civ.objects.DISTRICT).features)
.enter().append("path")
.attr("d", path);
svg.append("path")
.attr("class", "districts-borders")
.attr("d", path(topojson.mesh(civ, civ.objects.REGION, function(a, b) { return a !== b; })));
svg.append("path")
.attr("class", "districts-borders")
.attr("d", path(topojson.mesh(civ, civ.objects.DEPARTEMENT, function(a,b) {return a !==b;})));
svg.append("path")
.attr("class", "sousprefectures-borders")
.attr("d", path(topojson.mesh(civ,civ.objects.SOUS_PREFECTURE, function(a,b) {return a !== b;})))
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment