VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/android-jetpack-compose-how-to-use-google-maps/

⇱ Android Jetpack Compose: How to Use Google Maps - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Android Jetpack Compose: How to Use Google Maps

Last Updated : 23 Jul, 2025

Many applications such as Swiggy, Zomato, Ola, and others use Google Maps within their application to display the location within their application. Most of these applications use Google Maps to display the details within their application. In this article, we will take a look at How to integrate Google Maps in Android using Jetpack Compose. 

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.

Step 2: Adding dependency to use Google Maps

Navigate to build.gradle file and add the below dependency in the build.gradle file. 

dependencies {
...
implementation("com.google.android.libraries.maps:maps:3.1.0-beta")
implementation("com.google.maps.android:maps-v3-ktx:2.2.0")
implementation("androidx.fragment:fragment:1.8.6")
implementation("com.google.android.gms:play-services-maps:19.1.0")
}

After adding the dependency simply click on the sync now option to install it. 


Step 3: Adding permissions and google maps API key

Navigate to app > AndroidManifest.xml file and add the below code in the application tag for adding the API key. 

<application
...
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="Enter your API key" />
</application>

Check out the below article on How to generate API key for Google Maps in Android.


Step 4: Create a new layout file for the map layout

Navigate to app > res, Right click on it, New > Directory and name it as layout. Now right-click on that directory and click on New > Layout resource file. Create a new XML file and name it map_layout and add the below code to it. Comments are added in the code to get to know it in detail. 

map_layout.xml:


Step 5: Create a new file for creating a Map

Navigate to app > kotlin+java > {package-name} Right click on it, New > Kotlin Class/File and name it as MapUtils and add the below code to it. Comments are added in the code to get to know it in detail. 

MapUtils.kt:


Step 6: Working with MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

MainActivity.kt:

Output:

👁 Android Jetpack Compose - How to use Google Maps Output

Comment

Explore