Flutter Google Map Example
A Flutter application demonstrate google map.
Plugin
google_maps_flutter from flutter team.
Usage
To use this plugin, add
as a dependency in your pubspec.yaml file.
Getting Started
Get an API key at https://cloud.google.com/maps-platform/.
Android
Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml
:
iOS
Specify your API key in the application delegate ios/Runner/AppDelegate.m
:
Objective-C
Swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
GMSServices.provideAPIKey("YOUR_API_KEY")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist
file
with the key io.flutter.embedded_views_preview
and the value YES
.
Both
You can now add a GoogleMap
widget to your widget tree.
The map view can be controlled with the GoogleMapController
that is passed to
the GoogleMap
's onMapCreated
callback.