当前位置:网站首页>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);
}
}
边栏推荐
- 由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
- 抓包整理外篇fiddler———— 会话栏与过滤器
- RPC - gRPC简单的demo - 学习/实践
- Zhongke Panyun - data analysis and forensics packet flag
- Zkevm (12) state proof of appliedzkp
- 【MATLAB】通信信号调制通用函数 — 窄带高斯白噪声的生成
- We believe that the development of consumer Internet will still be limited to the Internet industry itself
- Developing mqtt access program under QT
- 附件四:攻击方评分标准.docx
- 关于solidworks standard无法获得许可 8544问题的总结
猜你喜欢

Customize a pager needed in your project

Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis

RAC delete damaged disk group

20000 words will take you to master multithreading
![[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术](/img/87/e0469e280365ed0261e2b551ebd888.png)
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术

测试 CS4344 立体声DA转换器

附件六:防守工作简报.docx

定制一个自己项目里需要的分页器

Detailed comparison of Hynix emmc5.0 and 5.1 series

中科磐云—模块A 基础设施设置与安全加固 评分标准
随机推荐
红队视角下的防御体系突破之第二篇案例分析
【MATLAB】MATLAB 仿真数字带通传输系统 — ASK、 PSK、 FSK 系统
自动化测试selenium基础篇——webdriverAPI
【MATLAB】通信信号调制通用函数 — 傅里叶逆变换
[matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
Customize a pager needed in your project
如何构建属于自己的知识引擎?社群开放申请
Solve the problem of failed to load property source from location 'classpathapplication YML 'problem
[matlab] matlab simulation modulation system - DSB system
COMP1721 Creating Classes
Create ASM disk through DD
cmake
【MATLAB】MATLAB 仿真模拟调制系统 — FM 系统
When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
Unity中RampTex介绍和应用: 溶解特效优化
MySQL JDBC programming
附件四:攻击方评分标准.docx
海力士EMMC5.0及5.1系列对比详解
Use units of measure in your code for a better life
The second case analysis of the breakthrough of defense system from the perspective of the red team