Maps
here are the steps to integrate Google Maps.
- Go to the Google Cloud Console https://console.cloud.google.com/
- If you haven’t already, create a new project by clicking on the “Select a project” dropdown at the top of the page, and then clicking on “New Project”. Give your project a name and click on “Create”.
- Once you have created or selected a project, click on the hamburger menu (three horizontal lines) in the top left corner of the page and select “APIs & Services” from the dropdown menu.
- Click on the “Library” tab on the left-hand side of the page to see the available APIs.
- Search for “Maps SDK for Android” and select it.
- Click on the “Enable” button.
- Repeat steps 5-6 for the following API: Maps SDK for iOS
- Once you have enabled all the necessary APIs, go to the “Credentials” page by clicking on the “Credentials” tab on the left-hand side of the page.
- Click on the “Create credentials” button and select “API key”.
- You can then copy this API key and use it in your app to integrate Google Maps.
note: You have to add the Api key on both admin and user app.
Android
- Open the AndroidManifest.xml file for your Android app, which can be found in the following directory:
android/app/src/main/AndroidManifest.xml
. - Add the following code inside the
tag: <meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_API_KEY"/>
- Replace YOUR_API_KEY with the API key that you obtained from the Google Cloud Console.
IOS
go to
ios/Runner/AppDelegate.swift
.Add the following code snippet to the AppDelegate.swift file:
import UIKit import Flutter import GoogleMaps @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GMSServices.provideAPIKey("YOUR_API_KEY_HERE") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } }
Replace YOUR_API_KEY_HERE with the API key that you obtained from the Google Cloud Console.