World Map with D3.js and TopoJSON data from World Atlas in
https://github.com/d3/d3
https://github.com/topojson/topojson
https://github.com/topojson/world-atlas
| license: mit |
World Map with D3.js and TopoJSON data from World Atlas in
https://github.com/d3/d3
https://github.com/topojson/topojson
https://github.com/topojson/world-atlas
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <style>svg{width:100%;height:500px;margin:0px auto;}</style> | |
| <body> | |
| <script src="https://unpkg.com/d3@4"></script> | |
| <script src="https://unpkg.com/topojson-client@3"></script> | |
| <script> | |
| var svg = d3.select("body").append("svg"); | |
| var path = d3.geoPath().projection(d3.geoMercator()); | |
| d3.json("https://unpkg.com/world-atlas@1/world/110m.json", function(error, world) { | |
| if (error) throw error; | |
| svg.selectAll("path") | |
| .data(topojson.feature(world,world.objects.countries).features) | |
| .enter().append("path") | |
| .attr("d", path); | |
| }); | |
| </script> |