I attempted to create a 3D map, similar to Google Maps.
Thanks to ChatGPT and Three.js, I was able to implement the basic functionalities.
Features include:
- Basic grid rendering with corresponding tile textures
- Users can set the location they want to visit
- Users can adjust the current center position and zoom level using controls and Three.js’
OrbitControls
- Sun positioning and its lighting effects on Earth, allowing for realistic day/night transitions
- Configurable Google Tiles resolution, language, and type
- Real-time location measurement
- Real-time scale indicator
- Real-time distance measurement from the observation point to the ground
- Dynamic tile calculation and loading
- Real-time moon positioning
- Geolocation support
What were the challenges in implementing this?
First, I had to understand how zoom levels and tiles work in GIS. After consulting ChatGPT multiple times, I got a mostly correct answer. By following its explanations step by step, I eventually achieved the desired results. The key aspects involved:
- Converting latitude and longitude to Earth-centered coordinates
- Converting Earth-centered coordinates back to latitude and longitude
- Calculating tile
x, y
based on zoom level (z
) and coordinates to request the correct tile - Computing the grid’s vertices, normals, indices, and UVs for rendering tiles
- Implementing smooth tile transition animations
- Efficient tile caching to ensure smooth performance during rapid movement and zooming
This project may seem simple at first glance, but it involves a lot of GIS and WebGL texture mapping knowledge. It took me about a week of exploration to finally present this result to you.