当前位置:网站首页>Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
2022-07-04 05:01:00 【Young people who get up early】
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 Turn up the Gaud map - Search location Reverse geocoding
Gaode map development document
static Future<bool> openAmap(
double longitude,
double latitude, {
String? address,
String? title,
bool showErr = true,
}) async {
String url =
'${
Platform.isAndroid ? 'android' : 'ios'}amap://viewReGeo?sourceApplication=${
title??""}&lat=$latitude&lon=$longitude&dev=0';
if (Platform.isIOS) url = Uri.encodeFull(url);
try {
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
return true;
} else {
if (showErr) showToastCommon(' Unable to adjust Gaode map ');
return false;
}
} on Exception catch (e) {
if (showErr) showToastCommon(' Unable to adjust Gaode map ');
return false;
}
}
In fact, it is called Gaode map open api Reverse address resolution 
The results are as follows :
3 Coordinate type selection
It should be noted that dev Value of coordinate type
- 0 The longitude and latitude are encrypted , No need for national test encryption ;
- 1 Using latitude and longitude is unencrypted , Need national test encryption ;
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 Turn up the Gaud map - Navigation Route planning
Gaode map development document
/// Goth map calls Navigation
static Future<bool> openAmapNav(
double longitude,
double latitude, {
String? address,
bool showErr = true,
}) async {
String url =
'${
Platform.isAndroid ? 'android' : 'ios'}amap://navi?sourceApplication=amap&lat=$latitude&lon=$longitude&dev=0&style=2&poiname=${
address ?? ''}';
if (Platform.isIOS) url = Uri.encodeFull(url);
try {
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
return true;
} else {
if (showErr) showToastCommon(' Unable to adjust Gaode map ');
return false;
}
} on Exception catch (e) {
if (showErr) showToastCommon(' Unable to adjust Gaode map ');
return false;
}
}
It's actually called 
5 The prompt box uses GetX frame
static showToastCommon(String message) {
Get.defaultDialog(
title: " Tips ",
middleText: message,
backgroundColor: Colors.white,
titleStyle: const TextStyle(color: Colors.black),
middleTextStyle: const TextStyle(color: Colors.red),
textConfirm: " got it ",
confirmTextColor: Colors.white,
onConfirm: () {
Get.back();
},
radius: 8);
}
}
边栏推荐
- QT qtableview data column width adaptation
- 【Go】数据库框架gorm
- Unity中RampTex介绍和应用: 溶解特效优化
- Capturing and sorting out external Fiddler -- Conversation bar and filter
- Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
- When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
- 力扣 第 300 场周赛
- Secondary vocational group network security - memory Forensics
- 海力士EMMC5.0及5.1系列对比详解
- Annex VI: defense work briefing docx
猜你喜欢

中科磐云—D模块解析以及评分标准

在代码中使用度量单位,从而生活更美好

Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it

Introduction and application of rampax in unity: optimization of dissolution effect

中職組網絡安全—內存取證

RPC - gRPC简单的demo - 学习/实践

Trie数-字典树

Unity 接入天气系统

YoloV6实战:手把手教你使用Yolov6进行物体检测(附数据集)

中科磐云—2022广东木马信息获取解析
随机推荐
Yolov6 practice: teach you to use yolov6 for object detection (with data set)
Zhongke Panyun - data analysis and forensics packet flag
中科磐云—数据分析与取证数据包flag
中科磐云—2022广东木马信息获取解析
Annex V: briefing on the attack process docx
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
[matlab] matlab simulation modulation system - DSB system
qt下开发mqtt的访问程序
MySQL indexes and transactions
LeetCode136+128+152+148
NTFS security permissions
Annex I: power of attorney for 202x XXX attack and defense drill
RAC delete damaged disk group
Annex II: confidentiality agreement for offensive and defensive drills docx
附件2-2保密承诺书.docx
PostgreSQL 正式超越 MySQL,这家伙也太强了吧!
【MATLAB】MATLAB 仿真模拟调制系统 — DSB 系统
【MATLAB】MATLAB 仿真数字基带传输系统 — 数字基带传输系统
Public inputs in appliedzkp zkevm (13)
【MATLAB】MATLAB 仿真 — 窄带高斯白噪声