当前位置:网站首页>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);
}
}
边栏推荐
- [matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
- Annex II: confidentiality agreement for offensive and defensive drills docx
- A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
- C basic (VII) document operation
- [matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
- Maui introductory tutorial series (5.xaml and page introduction)
- Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
- 20000 words will take you to master multithreading
- MAUI 入门教程系列(5.XAML及页面介绍)
- KMP匹配字符串
猜你喜欢
2022 Guangdong provincial competition - code information acquisition and analysis flag
6-4 vulnerability exploitation SSH banner information acquisition
Drozer tool
VSCode的有用插件
测试 CS4344 立体声DA转换器
【QT】定时器
RAC delete damaged disk group
Annex V: briefing on the attack process docx
KMP匹配字符串
C basic (VII) document operation
随机推荐
Operate the server remotely more gracefully: the practice of paramiko Library
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
[matlab] matlab simulation modulation system - DSB system
Secondary vocational group network security - memory Forensics
The second case analysis of the breakthrough of defense system from the perspective of the red team
Solve the problem of failed to load property source from location 'classpathapplication YML 'problem
技术管理 - 学习/实践
Detailed comparison of Hynix emmc5.0 and 5.1 series
National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
Correct the classpath of your application so that it contains a single, compatible version of com. go
Beipiao programmer, 20K monthly salary, 15W a year, normal?
【MATLAB】MATLAB 仿真数字带通传输系统 — ASK、 PSK、 FSK 系统
中科磐云—数据分析与取证数据包flag
Notes on the paper "cross view transformers for real time map view semantic segmentation"
我们认为消费互联网发展到最后,依然会局限于互联网行业本身
附件一:202x年xxx攻防演习授权委托书
Annex VI: defense work briefing docx
红队视角下的防御体系突破之第二篇案例分析
Deep understanding of redis -- bloomfilter
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3