当前位置:网站首页>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);
}
}
边栏推荐
- Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
- 中职组网络安全—内存取证
- Annex 4: scoring criteria of the attacker docx
- Share some of my telecommuting experience
- 简单g++和gdb调试
- 【MATLAB】MATLAB 仿真数字带通传输系统 — ASK、 PSK、 FSK 系统
- 20000 words will take you to master multithreading
- Zkevm (12) state proof of appliedzkp
- Binary search tree
- appliedzkp的zkevm(12)State Proof
猜你喜欢

Developing mqtt access program under QT

Yolov6 practice: teach you to use yolov6 for object detection (with data set)

Headache delayed double deletion

Unity中RampTex介绍和应用: 溶解特效优化

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

附件六:防守工作簡報.docx

NTFS security permissions

Sample template of software design document - learning / practice

Technology Management - learning / practice

Beipiao programmer, 20K monthly salary, 15W a year, normal?
随机推荐
QT qtableview data column width adaptation
电子元器件商城与数据手册下载网站汇总
Annex 2-2 confidentiality commitment docx
Correct the classpath of your application so that it contains a single, compatible version of com. go
RAC delete damaged disk group
Sample template of software design document - learning / practice
Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
技术管理 - 学习/实践
【QT】定时器
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
Exercise bubble sort
TCP状态转换图
【无标题】
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
【MATLAB】MATLAB 仿真 — 低通高斯白噪声
《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
C basic (VII) document operation
中職組網絡安全—內存取證
20000 words will take you to master multithreading
The first introduction, stages and methods of defense system breakthrough from the perspective of the red team