Preface I mentioned before that I am working on a location-based application. Recently, we need to make a location navigation function that allows users to navigate from their current location to a specified destination (by default, navigation is by driving). Navigation methods on mobile phones are divided into in-app navigation and out-of-app navigation
Speaking of in-app navigation, I was badly cheated by Tuba back then. Two years ago, when Amap and Baidu had not yet launched navigation SDKs, it seemed that only Tuba had an in-app navigation SDK on the market, so I had to use Tuba SDK. Today, Tuba SDK is still the most difficult map SDK to use in my mind (By the way, the design of Baidu's SDK and Tuba SDK seems to be in the same vein. I wonder if Baidu poached a large number of people from Tuba when it was making maps?). Moreover, this difficult SDK is still charged. Today I am going to talk about the second method. Because the information on the Internet is not very comprehensive, I will summarize the research results on this method today. Research Let's first look at what we want to achieve. When we click on the navigation, the following selection list will pop up. Of course, if a map APP is not installed, the corresponding option will not appear. To check whether the APP is installed, just call the following method.
I won’t introduce the URL Scheme of APP here, you can study it on your own. So the four map applications mentioned in the figure above are
These are the most commonly used maps at present (what do you mean, there is also Tencent Maps? Unfortunately, Tencent Maps does not support opening with URIs yet, so I will add it when it is available) Let's compare several maps.
Apple Maps is built-in (and the best way to open Apple Maps is not to use URI), so it can be opened without URL Scheme. Secondly, it is a good experience to be able to jump back after jumping to the map APP (refer to WeChat jump). Unfortunately, neither Apple Maps nor Baidu Maps support jumping back. Next, let's get back to the topic and talk about the jump method of each map. Assume we have a specified destination coordinate coordinate and our own APP URL Scheme is urlScheme name is appName
Apple Maps Apple Maps can be opened via openURL
However, this method cannot use the current location as the starting point, so it does not meet our requirements. It is said that the following method can be used online, but I did not succeed.
But Apple provides another way to use MKMapItem
The effect is as follows Baidu Map
A few things to note
The effect is as follows #p#Amap
A few things to note
The effect is as follows After exiting navigation, you will be prompted whether to jump back to the APP Google Maps
A few things to note
The effect is as follows: When there are multiple routes, Google Maps will let you choose one of them After selecting, you will enter the navigation page Tencent MapsSince we mentioned Tencent Maps, let's talk about the URIs that can be called from the Internet and official documents.
But unfortunately, an error occurred after the call and I cannot navigate The effect is as follows summary The demo in this article can be found here Relatively speaking, Amap is more attentive, after all, it is also a service provider for Apple. Baidu is relatively inferior. Google is still unusable without a VPN. As for Apple's own map, I won't say much about it. The function is still too simple. Here we just use the simplest way to call the navigation function. In fact, there are still many parameters and functions of each map that have not been used. Students who need to know can find detailed descriptions in the document link at the beginning of the article. |
<<: Debugging tips you may not know
>>: Why do most programmers' side projects die?
(This report is about 4,200 words and takes about...
The Xi'an Mercedes-Benz oil leak incident not...
WeChat Mini Program is an application that users ...
Before reading this article, we need to have a co...
Early stage of operation : quickly familiarize yo...
In the traditional forms of domestic activities, ...
How to save a "starved" battery? In fac...
The Sun is the only star in our solar system, but...
A design that can stimulate users' desire to ...
The story begins on an ordinary flight. A passeng...
Now that the weather is getting colder, there are...
A friend previously left a message asking Qinggua...
In the circle of friends and subscription list of...
Digital life, online communication, electronic co...
Suxuan Growth Academy's low-cost customer acq...