May 9, 2025
Core Packages: Use
google_maps_flutter
for rendering andgeolocator
for GPS and permissions.Permission Handling: Prompt for runtime location access and manage denied states gracefully.
User Location Focus: Animate camera to the user's real-time position via map controller.
Interactive Markers: Add map interactivity by handling taps and placing markers dynamically.
Platform-Specific Setup: Configure Android and iOS with proper API keys and permissions.
Scalability Potential: This setup enables advanced features like routing and geofencing.
Introduction
Integrating google maps into a Flutter app enhances user experience by visualizing data on an interactive map and leveraging location services for real-time positioning. In this intermediate tutorial, you’ll learn how to combine the google_maps_flutter plugin with Geolocator to display a map, request location permissions, and center the map on the user’s current position. We assume you have a basic Flutter setup and familiarity with asynchronous code.
Setting Up Dependencies and API Key
Begin by adding two packages to your pubspec.yaml:
• google_maps_flutter: the official Maps SDK for Flutter
• geolocator: simplifies access to device GPS and permissions
Next, obtain an Android and iOS API key from Google Cloud Console:
• Enable “Maps SDK for Android” and “Maps SDK for iOS.”
• Restrict the key by package name and SHA-1 (Android) and bundle ID (iOS).
Add your key to AndroidManifest.xml under :
And in iOS’s Info.plist:
Displaying the Google Map
Create a stateful widget to host GoogleMap. Define an initial camera position and a map controller.
This code displays a bare map using the Maps SDK and lets you later animate the camera to the user’s location.
Requesting Location Permissions
Before accessing GPS, request runtime permission via Geolocator. Handle denied or restricted states gracefully.
Call _determinePosition() when the widget initializes or when the user taps a “go to my location” button.
Centering Map on User Location
Once you have a Position object, animate the camera to the user’s coordinates.
Add a FloatingActionButton to invoke this method:
This gives users quick access to their current spot on the map.
Adding Markers and Interactivity
Markers help pinpoint points of interest. Maintain a Set in state:
Enable onTap on the map widget:
Each tap adds a new marker, demonstrating basic map interactivity.
Handling Platform Differences
iOS requires an additional key in Info.plist for location usage:
Android 12+ mandates AndroidManifest.xml permissions:
Test both platforms to ensure consistent behavior in permission dialogs and Maps SDK rendering.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
By following these steps, you’ve integrated google maps_flutter and geolocator into a Flutter project, displayed a map, handled permissions, fetched the user’s location, animated the camera, and added interactive markers. This foundation lets you build advanced features such as route drawing, clustering, or geofencing.