Responsive interactive D3.js map
D3.js Map with zoom/pan and rollover labels:
- Uses D3.js(v4) and JQuery
- Displayed within "map-holder" div to allow easier placement on page.
- Initial zoom is to show the map as small as possible without leaving whitespace at edges (i.e matching height of div or width of div, whichever is greater zoom)
- Initial translation is to show centre of map in centre of div
- ScaleExtent used to ensure map can't be zoomed out to smaller than initial value
- TranslateExtent used to ensure map can't be moved beyond inside of div
- Country name labels placed using Path.Centroid (some strange results for countries with remote colonies, e.g France)
- On resize of window the map SVG is resized, the zoom scaleExtent and translateExtent recalculated and the map zoomed and panned to new initial settings.
forked from andybarefoot's block: Responsive interactive D3.js map