Positioning of Gaode map developed by Android

In application development, map development is a "component" that often needs to be used. Although Google map has official tutorials, it can't be used. You know the reason ~ ~ then Baidu map and Gaode map are more famous in China. Due to personal preferences, Gaode map LBS is selected. Nonsense is not said and dry goods are available.

1. Register developers and create applications

This is a common practice for almost all open platforms, nothing more than registering an account, becoming a developer, and then creating an Android application, which will assign you a key to bind your service.

Register key.png

2. Download the SDK, import the jar package, and add to library

Jar package.png

The first is the jar package of 2D map, because I will mark the location on the map after the final location

The second is the jar package for locating

Note: if you are using 3D maps, the map SDK and navigation SDK need to import so library files. First create a jnilibs directory in APP / SRC / main / directory and put so in this directory

3. Configure the androidmainfest.xml file

4. Layout file for activity

Very simple, just a 2D map

5. Activity, the comments are very detailed

6. Run the program, click the customized "fire" pushpin, and the effect diagram is as follows:

Location Result.png

7. Long press the map screenshot and save the picture

The activity implements the amap.onmaplongclicklistener and amap.onmaplongclicklistener interfaces,

Then the declaration of the activity becomes:

The following two methods are implemented respectively

Supplement on August 26, 2016

Many Jian you followed the above process and found that they could not achieve my effect, so I summarized the possible reasons:

1. In androidmainfest.xml, you must put the key you applied for;

2. When applying for a key, there is a SHA-1. You must not be wrong. If you are wrong, you can't locate it, because once you are wrong, you can't identify your current application;

3. If you use 3D drawings, you must import the 3D library into the project. My case is 2D;

4. Be sure to test on the real machine.

If you have friends who cannot be located, please check according to the above error causes. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>