Skip to content

Instantly share code, notes, and snippets.

Forked from d3noob/.block
Created Jan 22, 2016
What would you like to do?
World Map with zoom and pan
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, 0])
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));
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