Globe with rotating animation and country label

user profile photouser profile photouser profile photo232 developers have joined this project.

What you will practice

You'll practice how to use JavaScript and the D3.js library to create a rotating globe. This project also requires basic knowledge of drawing on canvas or via SVG.

Introduction

We would like to create a globe on a web page that paints out all continents. Users can select a country to rotate the globe to center on that country.

Within this project, you'll learn about how to use d3-geo API, the concept of projection, and how to draw on a canvas or SVG. Depending on your experience with JavaScript and D3.js, it might take you 8 to 16 hours to complete this project.

Requirements

  • Display a globe at the center of the web page
  • A selector for the user to choose a country. We suggest a dropdown list or text input.
  • When the user selects a country, the globe should rotate with a transition animation and center to the country selected.
  • Highlight the continent that the country belongs.
  • On the globe, display the names of all other countries in the same continent as the selected country.

The following image shows one way to implement the UI. Feel free to interpret the requirements however you'd like!
Globe with rotating animation project demo

For an extra challenge: Allow the user to select the country by clicking on the globe.

Suggested Implementation

  • We suggest starting off with creating a globe with d3. Your globe should be able to be centered on any country location without animation.
  • Next, pass the value of the selected country to this globe module, which would then center the globe to the passed country.
  • The last step would be to add in the transition animation.

References

  • D3 Geo API: Geographic projections, spherical shapes and spherical trigonometry.
  • Globe with rotation controls reference
  • Rotating globe with location marker reference
  • You'll need a list of country names and country code mapping - reference

Hit a programming wall?
Get help from our mentors

  • Post request free
  • First 15 mins free

Suggested languages and frameworks

HTML/CSSD3.jsJavaScript

Difficulty

medium

Contributed by

Front-End Lead @ Codementor | Dedicated and UX Focused Developer

Interested in this project?

Shorten your learning curve with on-demand programming help

The awesome set of verified mentors will provide guidance and mentoring help when you are stuck.

Suresh Atta

  • Post request free
  • First 15 mins free
Shorten your learning curve with on-demand programming help

Browse more projects

More coming soon...