May 2019
Beginner to intermediate
650 pages
14h 50m
English
A projection is like a two-dimensional scale function. To use it, first create a function:
const projection = d3.geoMercator();
Now you can pass it to a geoPath, or use it to convert spherical coordinates into pixels and back:
const geoPath = d3.geoPath();geoPath.projection(projection); const pixels = projection([-45,23]); // convert location to pixelsconst coords = projection.invert(pixels); // and back
Once a geoPath is configured with a projection, you can render it The standard viewport has a default dimension of 900x500 pixels. You don't have to make your map fit that area, but you should be aware of it since the methods that transform the projection in the viewport assume these default values.
You can configure a ...
Read now
Unlock full access