This Flutter project demonstrates how to add 3D vehicle models on top of Google Maps, creating an interactive and visually appealing map experience similar to ride-sharing apps like Uber. The project uses pre-rendered 3D models and real-time coordinate conversion to achieve smooth animations and rotations of vehicles on the map.
What's This All About?
7_days_of_flutter_fun.mov
Find more about the 7 day flutter challenge here.
- Integration with Google Maps in Flutter
- Custom 3D vehicle markers using pre-rendered images
- Smooth animation of vehicle position and rotation
- Real-time conversion of geographic coordinates to screen coordinates
- Multiple vehicle support with independent movements
- Optimized performance for mobile devices
- Google Maps API key
- Clone this repository:
git clone https://github.com/yourusername/flutter_google_maps_3d_pins.git
- Navigate to the project directory:
cd flutter_google_maps_3d_pins
- Install dependencies:
flutter pub get
- Add your Google Maps API key:
- Replace
YOUR_API_KEYwith your actual API key
- Run the app:
flutter run
lib/main.dart: Entry point of the applicationlib/map_with_overlay.dart: Main widget for Google Maps integration and 3D vehicle renderinglib/car_marker_widget.dart: Widget for rendering the 3D vehicle markerlib/route.dart: Classes for handling route datalib/data/notifier.dart: State management for vehicle positions and rotations
-
3D Model Preparation: We use pre-rendered images of a 3D vehicle model from 60 different angles.
-
Google Maps Integration: The app uses the Google Maps Flutter plugin to display the map.
-
Coordinate Conversion: Geographic coordinates (latitude, longitude) are converted to screen coordinates in real-time.
-
Animation: Vehicle markers are animated using Flutter's animation system for smooth movement and rotation.
-
State Management: The app uses Riverpod for efficient state management of vehicle positions and rotations.
- To use a different 3D model, replace the images in the
assets/images/truck/directory. - Adjust the number of pre-rendered images by modifying the
imageCountconstant incar_marker_widget.dart. - Customize vehicle movement patterns by modifying the
updateRoutemethod indata/notifier.dart.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
