Menu

1 / 3

I built a globe where every country is a separate piece you can pull out ๐ŸŒ

DEV Community: reactยทMuhammad Ahmadยท15 days ago
#8SKsGPnt
#devtoreact#devto#dev#country#every
Reading 0:00
15s threshold

Hey everyone ๐Ÿ‘‹

Most web globes are a texture wrapped around a sphere. You can spin them, and that's about it.

I wanted one where every country is a real object : its own plate, set into the ocean ball like a puzzle piece. So I built it.

It's all SVG and a bit of math, with no WebGL and no canvas.

What you can do ๐ŸŽฎ

Drag to turn the globe any way

Click a country to pull it out of its socket

Break the whole map apart with one button, then let it settle back

Pull out a big country like Canada, the US or Pakistan and it splits into its states or provinces , each one a plate with its name on it.

How it works ๐Ÿ› ๏ธ

The ball is a projection. Natural Earth's outlines go through a d3-geo orthographic projection. When you drag, nothing moves: the globe rotates and every country is projected again.

Each country is its own plate. It has a top, walls, a socket it leaves behind and a shadow, so it can lift out on its own spring while the others stay put.

SVG has no depth buffer.โ€ฆ

Continue reading โ€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.