This project contains the results of learning research in implementing Google Maps on Flutter. Here is a demo of the flutter maps application
- Set limits on the reachable area
- Creates directions for navigating shipments that fall within the specified area
- Get current location (or realtime current location)
Flutter maps use several open source packages found in pub.dev, including :
- google_maps_flutter - this is used to display the map with the Google Maps SDK
- geocoding - to translate latitude and longitude coordinates into an address
- geolocator - provides easy access to platform specific location services
- flutter_polyline_points - that decodes encoded google polyline string into list of geo-coordinates suitable for showing route/polyline on maps
To use this project, it is required to setup the Google Maps SDK first, You can access the following guide Google Maps Platform or CodeLabs FLutter Maps
After successfully setting up the Google Maps SDK, you can replace the API Key into the following file :
and you can immediately run the flutter application with the following command
flutter pub get
flutter run lib/main.dart
To simulate the location , you need to do some modifications.
If you are on Windows or using the Android simulator, click on the bottom three dots and make sure you are in the location. Let's say the source location is Google Plex, change the source location to these coordinates and the destination location is your current location, please custom the area in the _listAreaLatLng
variable according to your location. Now click on the “route” tab, and look for the current location and Google plex as a starting point. Save route, set loop route press playback speed. The current location is moving which is what we want.