Stay organized with collections Save and categorize content based on your preferences.
IntroductionThis tutorial shows you how to add a Google map to your Flutter app. The map includes a marker, also called a pin, to indicate a specific location.
Getting the codeClone or download the Flutter samples repository. The sample code can be found in the google_maps
directory.
Be sure you've completed the steps outlined in the Set up a Flutter project guide before continuing with this topic.
1. Import the Google Maps for Flutter packagemain.dart
file in your preferred IDE.import 'package:google_maps_flutter/google_maps_flutter.dart';2. Add Google Maps to your Flutter app
Within the Scaffold
widget, add a GoogleMap
widget as the body.
GoogleMap( initialCameraPosition: CameraPosition( target: _center, zoom: 11.0, ), markers: { const Marker( markerId: MarkerId('Sydney'), position: LatLng(-33.86, 151.20), ) }, )
markerId
option labels your marker.position
option sets where the marker appears on your map.Start the Flutter app using one of the following options:
Run
buttonflutter run
.You should see a map with a marker centered on Sydney on the east coast of Australia, similar to the image on this page.
Troubleshootingcom.google.examples.map-with-marker
.This code can be found on GitHub.
import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; void main() => runApp(const MyApp()); class MyApp extends StatefulWidget { const MyApp({super.key}); @override State<MyApp> createState() => _MyAppState(); }
class _MyAppState extends State<MyApp> { late GoogleMapController mapController; final LatLng _center = const LatLng(-33.86, 151.20); void _onMapCreated(GoogleMapController controller) { mapController = controller; }
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Maps Sample App'), backgroundColor: Colors.green[700], ), body: GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: _center, zoom: 11.0, ), // CameraPosition ), // GoogleMap ), // Scaffold ); // MaterialApp } }
body: GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: _center, zoom: 11.0, ), markers: { const Marker( markerId: const MarkerId("Sydney"), position: LatLng(-33.86, 151.20), ), // Marker }, // markers ), // GoogleMap ...
const Marker( markerId: const MarkerId("Sydney"), position: LatLng(-33.86, 151.20), infoWindow: InfoWindow( title: "Sydney", snippet: "Capital of New South Wales", ), // InfoWindow ), //Marker ...By default, the Google Maps for Flutter package displays the content of the info window when the user taps a marker. There's no need to add a click listener for the marker if you're happy to use the default behavior.
Congratulations! You've built an Flutter app that displays a Google map with a marker to indicate a particular location and provide additional information in an info window. You've also learned how to use the Google Maps for Flutter package.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This tutorial provides a step-by-step guide on integrating a Google map with a marker into your Flutter application."],["You will learn how to import the necessary package, add the Google Map widget, and position a marker using latitude and longitude coordinates."],["The tutorial covers troubleshooting common issues like API key setup, connectivity problems, and debugging techniques."],["It also includes a detailed explanation of the code, breaking down the process of initializing the map, adding markers, and displaying information windows."],["You can find the complete source code on GitHub for easy reference and implementation in your projects."]]],["To add a Google Map to a Flutter app, first, import the `google_maps_flutter` package. Within the `Scaffold` widget, add a `GoogleMap` widget, setting the `initialCameraPosition` and `markers`. Each marker requires a `markerId` and `position`. Run the app using the IDE or command line (`flutter run`). To add information to a marker use `infoWindow`. Debugging involves checking for an API key, connection issues, and using Flutter DevTools. The code is also available on Github.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4