当前位置:网站首页>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
边栏推荐
猜你喜欢
MSYQL, redis, mongodb visual monitoring tool grafana
As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform
How is the combination of convolution and transformer optimal?
Canonical的工程师们正努力解决Firefox Snap的性能问题
How important is it to make a silver K-line chart?
What about frequent network disconnection of win11 system? Solution to win11 network instability
如何设置 Pod 到指定节点运行
One hour to build a sample scenario sound network to release lingfalcon Internet of things cloud platform
【观察】软通动力刘天文:拥抱变化“顺势而为”,做中国数字经济“使能者”...
做白银k线图有多重要?
随机推荐
Luoqingqi: has high-end household appliances become a red sea? Casati took the lead in breaking the game
【观察】软通动力刘天文:拥抱变化“顺势而为”,做中国数字经济“使能者”...
[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~
static静态成员变量使用@Value注入方式
MBA-day19 如果p则q矛盾关系p 且非q
14,04 millions! Appel d'offres pour la mise à niveau de la base de données relationnelle et du système logiciel Middleware du Département des ressources humaines et sociales de la province du Sichuan!
【U盘检测】为了转移压箱底的资料,买了个2T U盘检测仅仅只有47G~
4-2 port banner information acquisition
Win11策略服务被禁用怎么办?Win11策略服务被禁用的解决方法
Creators foundation highlights in June
3-2主机发现-三层发现
Exploration and practice of NLP problem modeling scheme
3-3主机发现-四层发现
nacos 问题
Tiger painter mengxiangshun's digital collection is on sale in limited quantities and comes with Maotai in the year of the tiger
WPS and Excelle
The list of winners in the classic Smurfs of childhood: bluedad's digital collection was announced
Connaissance générale des paramètres de sécurité du serveur Cloud
Go: how to write a correct UDP server
mysql远程连接