Skip to main content
100%

Center and Scale your map

✓ Published0🌍 Public
LLuisSevillano
Last edited Oct 7, 2017
Created on Oct 7, 2017

This example demonstrates how to center and scale a map projection to fit a specific geographic feature, using a TopoJSON dataset of the A Coruña region. It shows the city boundary and coastline rendered as SVG paths, with a light blue background and gray land fill. The code computes the feature's bounds and centroid with `d3.geoBounds` and `d3.geoCentroid`, then uses `d3.geoDistance` to calculate an appropriate scale for the Mercator projection so the map is properly framed.

AI-generated description

Most basic example to center and scale your map with d3.geoBounds(), d3.geoCentroid() and d3.geoDistance().

Similar vizzes