zcreativelabs / react-simple-maps

Beautiful React SVG maps with d3-geo and topojson using a declarative api.
https://www.react-simple-maps.io/
MIT License
3.12k stars 426 forks source link

Projections #180

Closed bnbon closed 4 years ago

bnbon commented 4 years ago

Hello,

I was using 0.12.x and updated to 2.x.x apart from a one line fix, my map worked great - but I had to remove projection="robinson" from the ComposableMap component; why is this?

zimrick commented 4 years ago

Hi @bonbonio,

Great that your upgrade was largely problem free and thanks for using react-simple-maps.

Regarding the projection, the Robinson projection is part of the d3-geo-projection package. In order to reduce the size of react-simple-maps, we opted to remove that package and make it optional for those who want these other projections.

The Equal Earth projection is very similar to the Robinson projection, though it is an equal area projection, whereas Robinson is a compromise projection. Since a lot of people want to make choropleth maps, it's better that an equal area projection is the default. The Equal Earth projection is part of the core d3-geo package, so it doesn't require an additional package to be included with react-simple-maps.

If you want to use Robinson, it is possible to pass a projection from d3-geo-projection as a function to React Simple Maps. Just make sure to add d3-geo-projection as a dependency of your project.

Check out this example: https://codesandbox.io/s/custom-projection-with-react-simple-maps-f5vbf

bnbon commented 4 years ago

Hi @zimrick

Thank you for such a prompt and interesting reply - that has answered my question perfectly - and is very much appreciated.