Working with AMap in Android – Part 1(Getting Started with AMaps)

While working on a Chinese project. We faced a problem which is in China the Google services are blocked. Yes, you will not have any of the important Google services like Firebase, maps etc.

We found an alternative for the maps which is AMaps. AMaps actually works just like google maps but it’s actually a Chinese product. So to get the locations, maps, and routes in China you can use AMaps as an alternative.

 

Let’s get started with showing a basic map on your in your activity.

First, you need to setup your AMaps and for that, you need to register yourself here and get a Key to use it’s all functionality in the application. Key is not required to show the maps, locations, and markers but it is essential for showing routes and other functionalities similar to it.

 

After getting the Key from the site. You need to download SDKs from here. You can also download the sample code from here which is very helpful to understand and use in your application.

 

Install the libraries in your project and add the key (if you have) in your AndroidManifest.xml file in meta-data tag.

 

And also the required permission to access internet and location and if you want to work with offline maps you can also add read-write store permission.

 

Now when you are all set to work with AMaps. Let’s begin with creating a layout for maps.

To get the maps you need to add the maps tag in your XML layout file like the below code.

You can always change the width and height attributes to change map view this will represent the area in which the map will be displayed.

 

After adding the maps in your layout you can instantiate it in onCreate method of your Activity like the below code.

 

That’s all !!! Connect your device and start working with AMaps. We will discuss some other features of AMaps in the next blog.

Thank you very much, this is Vedesh Kumar signing off.

PART 2 —–>

. . .

Comment

Add Your Comment

Be the first to comment.

css.php