Skip to content

Instantly share code, notes, and snippets.

Last active December 4, 2020 09:33
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
World Map with zoom and pan
license: mit
World map with pan and zoom
<!DOCTYPE html>
<meta charset="utf-8">
path {
stroke: white;
stroke-width: 0.25px;
fill: grey;
<script src=""></script>
<script src=""></script>
var width = 960,
height = 500;
var projection = d3.geo.mercator()
.center([0, 5 ])
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
var path = d3.geo.path()
var g = svg.append("g");
// load and display the World
d3.json("world-110m2.json", function(error, topology) {
.data(topojson.object(topology, topology.objects.countries)
.attr("d", path)
// zoom and pan
var zoom = d3.behavior.zoom()
.on("zoom",function() {
.attr("d", path.projection(projection));
Display the source blob
Display the rendered blob
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