当前位置:网站首页>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);
}
}
边栏推荐
- Annexe VI: exposé sur les travaux de défense. Docx
- Sample template of software design document - learning / practice
- Deep understanding of redis -- bloomfilter
- VSCode的有用插件
- KMP匹配字符串
- 在代码中使用度量单位,从而生活更美好
- 【MATLAB】MATLAB 仿真模拟调制系统 — DSB 系统
- Simple g++ and GDB debugging
- QT qtableview data column width adaptation
- laravel 中获取刚刚插入的记录的id
猜你喜欢

MySQL JDBC programming

附件五:攻击过程简报.docx

appliedzkp zkevm(13)中的Public Inputs

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

Download kicad on Alibaba cloud image station

《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记

National vocational college skills competition (secondary vocational group) network security competition questions - Analysis

RPC - grpc simple demo - learn / practice

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

NTFS security permissions
随机推荐
Encryption and decryption
Can closed data be deleted by DBCA? can
Trie数-字典树
Several smart watch related chips Bluetooth chip low power consumption
抓包整理外篇fiddler———— 会话栏与过滤器
[matlab] matlab simulation - simulate the AM modulation process of the modulation system
Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire
[go] database framework Gorm
Qt QTableView数据列宽度自适应
测试 CS4344 立体声DA转换器
【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(第 I 类部分响应波形)的眼图
When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
KMP匹配字符串
附件2-2保密承诺书.docx
Useful plug-ins for vscode
Zhengzhou zhengqingyuan Culture Communication Co., Ltd.: seven marketing skills for small enterprises
记几个智能手表相关芯片 蓝牙芯片 低功耗
Customize a pager needed in your project
Yolov6 practice: teach you to use yolov6 for object detection (with data set)
Headache delayed double deletion