Skip to main content
100%

Test Zooming and panning of a Mercator map using d3.js.

✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Feb 16, 2013

This example demonstrates panning and zooming of a Mercator-projected world map built with D3.js. The map auto-rotates via a timer, while a d3.behavior.zoom event handler updates the transform of an inner "g" element to support mouse-driven pan and zoom. The map is rendered as SVG paths, using d3.geo.path and a d3.geo.mercator projection, with topology data loaded from a GeoJSON file. The implementation highlights the challenge of centering the map on the international date line due to projection rotation limitations.

AI-generated description

Development File to test zooming and panning of a map using d3.js.

The map pans automatically with a timer function and can be panned and zoomed with a mouse.

However, I've come up against a brick wallin my understanding since I can see that I'm panning and zooming the internal "g" element within the "svg" element.

Full disclosure: This is not my ultimate aim. What I really want is the ability to pan and zoom a Mercator style map, but to have its starting position centred on the international date line (in the middle of the pacific). For some reason this is problematic and I don't understand why.

mit Licensed

Similar vizzes