xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mercator projection</title>
<script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script>
<style type="text/css">
body {
margin: 0;
background-color: lightGray;
font-family: Helvetica, Arial, sans-serif;
}
#container {
width: 1200px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
padding: 20px;
background-color: white;
box-shadow: 5px 5px 8px 9px #ccc;
}
h1 {
font-size: 30px;
margin: 10;
}
p {
font-size: 14px;
margin: 14px 0 0 0;
}
a:link {
text-decoration: none;
color: gray;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: gray;
}
a:active {
color: steelBlue;
}
svg {
background-color: white;
}
</style>
</head>
<body>
<div id="container">
<h1>Italy</h1>
</div>
<script type="text/javascript">
//Width and height
var w = 1000;
var h = 1000;
//Define map projection
var projection = d3.geo.conicEqualArea()
.center([ 20, 40 ])
.translate([ w/1, h/1.8 ])
.scale([ 4000 ]);
//Define path generator
var path = d3.geo.path()
.projection(projection);
//Create SVG
var svg = d3.select("#container")
.append("svg")
.attr("width", w)
.attr("height", h);
//Load in GeoJSON data
d3.json("italy.json", function(json) {
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path);
});
</script>
</body>
</html>
https://d3js.org/d3.v3.min.js