当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
Download kicad on Alibaba cloud image station
Notes on the paper "cross view transformers for real time map view semantic segmentation"
Useful plug-ins for vscode
《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
6-5 vulnerability exploitation SSH weak password cracking and utilization
Headache delayed double deletion
NTFS security permissions
qt下开发mqtt的访问程序
Technology Management - learning / practice
随机推荐
Correct the classpath of your application so that it contains a single, compatible version of com.go
Create ASM disk through DD
appliedzkp zkevm(13)中的Public Inputs
附件五:攻击过程简报.docx
记几个智能手表相关芯片 蓝牙芯片 低功耗
Customize a pager needed in your project
附件六:防守工作簡報.docx
When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
Secondary vocational group network security - memory Forensics
[matlab] matlab simulation modulation system - DSB system
Deep understanding of redis -- bloomfilter
【无标题】
【Go】数据库框架gorm
Binary search tree
网络设备应急响应指南
[matlab] matlab simulation - low pass Gaussian white noise
ADB tools
How to build your own knowledge engine? Community open application
如何构建属于自己的知识引擎?社群开放申请
加密和解密