当前位置:网站首页>Flutter calls Baidu map app to realize location search and route planning
Flutter calls Baidu map app to realize location search and route planning
2022-06-29 19:44:00 【Young people who get up early】
Aspiring climber , I will not be intoxicated by some footprints along the way , In the world of Manon , Beautiful application experience , It comes from the programmer's handling of details and the realm of self requirements , Young people are also one of the busy yard farmers , Every day 、 Once a week , Will leave some footprints , It's the content of these creations , There is a kind of persistence , I don't know why , If you are confused , Let's take a look at the path of the yard farmer .
1 The development of preparation
pubspec.yaml Add a plug-in to the configuration file
dependencies:
flutter:
sdk: flutter
url_launcher: ^6.1.2
iOS To configure info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>iosamap</string>
<string>baidumap</string>
</array>
2 Flutter Tune up Baidu map - Search location
Baidu map development document
/// Baidu Maps
static Future<bool> openBaiduMap(
double longitude,
double latitude, {
String? address,
bool showErr = true,
String? title,
}) async {
String url =
"bdapp://map/geocoder?location=$latitude,$longitude&src=$title&coord_type=gcj02";
if (Platform.isIOS) url = Uri.encodeFull(url);
try {
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
return true;
} else {
if (showErr) showToastCommon(' Unable to adjust Baidu map ');
return false;
}
} on Exception catch (e) {
if (showErr) showToastCommon(' Unable to adjust Baidu map ');
return false;
}
}
In fact, it is called Baidu map open api Reverse address resolution 
The results are as follows :
3 Coordinate type selection
It should be noted that coord_type Value of coordinate type
- bd09ll( Baidu latitude and longitude coordinates )
- bd09mc( Baidu Mercator coordinates )
- gcj02( Coordinates encrypted by the National Survey Bureau )
- wgs84(gps The original coordinates obtained )
If you do not pass the correct coordinate type parameter , It will cause the location coordinates to shift . The default is bd09 Latitude and longitude coordinates .
4 Flutter Tune up Baidu map - Navigation Route planning
Baidu map development document
static Future<bool> openBaiduMapNav(
double longitude,
double latitude, {
String? address,
bool showErr = true,
String? title,
}) async {
String url =
'baidumap://map/direction?destination=name:${
address ?? ''}|latlng:$latitude,$longitude&coord_type=bd09ll&mode=driving';
if (Platform.isIOS) url = Uri.encodeFull(url);
try {
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
}
} on Exception catch (e) {
if (showErr) showToastCommon(' Unable to adjust Baidu map ');
return false;
}
return true;
}
It's actually called 
边栏推荐
- Win11 system component cannot be opened? Win11 system widget cannot be opened solution
- 3-3主机发现-四层发现
- 终于,进亚马逊了~
- k线图经典图解(收藏版)
- KDD 2022 | 協同過濾中考慮錶征對齊和均勻性
- 3 - 3 découverte de l'hôte - découverte à quatre niveaux
- 做白银k线图有多重要?
- MBA-day26 数的概念与性质
- NLP - GIZA++ 实现词对齐
- AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
猜你喜欢

MBA-day26 数的概念与性质

3-3主機發現-四層發現

3-2主机发现-三层发现

Win11系统频繁断网怎么办?Win11网络不稳定的解决方法

Win11 system component cannot be opened? Win11 system widget cannot be opened solution

How important is it to make a silver K-line chart?
![[USB flash disk test] in order to transfer the data at the bottom of the pressure box, I bought a 2T USB flash disk, and the test result is only 47g~](/img/c3/e0637385d35943f1914477bb9f2b54.png)
[USB flash disk test] in order to transfer the data at the bottom of the pressure box, I bought a 2T USB flash disk, and the test result is only 47g~

Common knowledge of ECS security settings

La collection numérique Meng xiangshun, artiste national du tigre peint, est disponible en quantité limitée et est offerte avec Maotai de l'année du tigre

Shell bash script note: there must be no other irrelevant characters after the escape character \ at the end of a single line (multi line command)
随机推荐
正则表达式系列之手机号码正则
Creators foundation highlights in June
MBA-day26 数的概念与性质
一个mysql里有3306端口下,一个mysql有20多个数据库,怎么一键备份20多个数据库,做系统备份,防止数据误删除?
3 - 3 découverte de l'hôte - découverte à quatre niveaux
Game Maker 基金会呈献:归属之谷
Zotero journal Automatic Matching Update Influencing Factors
Flutter 2.0 FocusScope. of(context). The requestfocus (focusnode()) does not take effect
How to use filters in jfinal to monitor Druid for SQL execution?
JVM (4) Bytecode Technology + Runtime Optimization
In 2022, the financial interest rate has dropped, so how to choose financial products?
【剑指Offer】51. 数组中的逆序对
freeswitch拨打分机号
idea中方法上没有小绿色三角
数据基础设施升级窗口下,AI 新引擎的技术方法论
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
How is the combination of convolution and transformer optimal?
3-3 host discovery - layer 4 discovery
Game maker Foundation presents: Valley of belonging
Docker compose deploy the flask project and build the redis service