Android positioning and destination navigation example code

Today, I accidentally saw the demo of technology God using Baidu map to locate and realize destination navigation. I think it's very good. I'll reprint it and share it with you. Let's see the effect:

After entering, you will first get the current location and display it on the map. After entering the destination in the input box, the best route will appear on the map. What I set here is the driving route with the smallest distance. In addition, there are bus routes and pedestrian routes. There are detailed notes in the code. In addition, the console also outputs the information of each node on the line and the distance between the starting position and the destination. The information displays the navigation information at the current node. As shown below:

Next, let's see how to implement it. First, register the baidu developer account, enter the baidu map API to view the relevant information, and then register the app key for the application that needs to be added to the map. After registration, download the baidu map jar file, create a new project, and import it. See the implementation code below. There are detailed comments in the code:

Then the layout file:

AndroidMainifest.xml

The above is all the code to realize Baidu map positioning and destination navigation. I don't know if it's what you want?

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support 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
分享
二维码
< <上一篇
下一篇>>