How to Integrate MapmyIndia Maps in Android?
We will get to see many android applications displaying maps within their applications to display user locations or delivery boy locations within their application. We will get to see the applications using google maps or maps provided by Maps My India. Map My India is an SDK that provided the functionality to integrate maps functionality within our application. In this article, we will take a look at How to integrate Map My India SDK in an Android application to display Maps.
Note: This Android article covered in both Java and Kotlin languages.
Step by Step Implementation
Step 1: Create a New Project in Android Studio
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Step 2: Downloading SDK for Map My India
Navigate to the link and download the jar file for Map My India SDK. After downloading it copy the file to add it to our project. Navigate to the Project section in your android studio project. Then navigate to Project Name > app > libs. Right-click on it and simply paste the downloaded jar file into that folder.
Step 3: Adding dependency in build.gradle file
Navigate to app > build.gradle file and add the below dependency to it in the dependencies section.
implementation 'com.google.code.gson:gson:2.3' implementation files('libs/map_sdk_2.1.jar')
After adding the dependency simply sync your project.
Step 4: Working with the activity_main.xml file
Navigate to app > res > layout > activity_main.xml and add the below code to it. Comments are added in the code to get to know in detail.
Step 5: Adding permissions in the AndroidManifest.xml file
Navigate to app > AndroidManifest.xml file and add the below permissions to it.
Now add the below code in the application tag in the AndroidManifest.xml file to use the legacy library within our application.
Step 6: Generating your API key for using Map My India SDK
Navigate to the link. Sign Up with your email and password and you will get to see the below screen. Inside that navigate to the credentials tab to see your API key. Copy that API key that we have to use in our project.
Step 7: Working with the MainActivity file
Navigate to app > java > your app’s package name > MainActivity file and add the below code to it. Comments are added in the code to get to know in detail.
Now run your application to see the output of it.
Please Login to comment...