当前位置:网站首页>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);
}
}
边栏推荐
- 每日刷题记录 (十二)
- 自动化测试selenium基础篇——webdriverAPI
- 中科磐云—数据分析与取证数据包flag
- STM32F1与STM32CubeIDE编程实例-74HC595驱动4位7段数码管
- PostgreSQL 正式超越 MySQL,这家伙也太强了吧!
- 网络设备应急响应指南
- [matlab] matlab simulation - low pass Gaussian white noise
- 【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(余弦滚降成形脉冲)的眼图
- Qt QTableView数据列宽度自适应
- We believe that the development of consumer Internet will still be limited to the Internet industry itself
猜你喜欢

全国职业院校技能大赛(中职组)网络安全竞赛试题—解析

Create ASM disk through DD

Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard

中职组网络安全—内存取证

软件设计文档示例模板 - 学习/实践

2022年6月总结

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

Utiliser des unités de mesure dans votre code pour une vie meilleure

Detailed comparison of Hynix emmc5.0 and 5.1 series

20000 words will take you to master multithreading
随机推荐
Trie数-字典树
Use units of measure in your code for a better life
Detailed comparison of Hynix emmc5.0 and 5.1 series
红队视角下的防御体系突破之第一篇介绍、阶段、方法
在代碼中使用度量單比特,從而生活更美好
Introduction and application of rampax in unity: optimization of dissolution effect
[matlab] matlab simulation modulation system FM system
Solve the problem of failed to load property source from location 'classpathapplication YML 'problem
中科磐云—D模块解析以及评分标准
Maui introductory tutorial series (5.xaml and page introduction)
附件四:攻击方评分标准.docx
【MATLAB】MATLAB 仿真数字基带传输系统 — 数字基带传输系统
【MATLAB】通信信号调制通用函数 — 带通滤波器
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
6-4 vulnerability exploitation SSH banner information acquisition
COMP1721 Creating Classes
记几个智能手表相关芯片 蓝牙芯片 低功耗
【MATLAB】通信信号调制通用函数 — 傅里叶变换
Useful plug-ins for vscode
Zhongke Panyun - data analysis and forensics packet flag