Skip to content

Commit

Permalink
Update: document
Browse files Browse the repository at this point in the history
  • Loading branch information
pdliuw committed Jun 27, 2020
1 parent db5ebd1 commit 783648b
Show file tree
Hide file tree
Showing 4 changed files with 335 additions and 13 deletions.
139 changes: 138 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,141 @@
|iOS-map|Android-map|
|:-|:-|
|![ios](https://github.com/pdliuw/ai_amap/blob/master/example/gif/ai_amap_ios.gif)|![android](https://github.com/pdliuw/ai_amap/blob/master/example/gif/ai_amap_android.gif)|
|:-|:-|
|:-|:-|


## 1.安装

使用当前包作为依赖库

### 1. 依赖此库

在文件 'pubspec.yaml' 中添加

[![pub package](https://img.shields.io/pub/v/ai_amap.svg)](https://pub.dev/packages/ai_amap)

```
dependencies:
ai_amap: ^version
```

或者以下方式依赖

```
dependencies:
# ai_amap package.
ai_amap:
git:
url: https://github.com/pdliuw/ai_amap.git
```

### 2. 安装此库

你可以通过下面的命令行来安装此库

```
$ flutter pub get
```

你也可以通过项目开发工具通过可视化操作来执行上述步骤

### 3. 导入此库

现在,在你的Dart编辑代码中,你可以使用:

```
import 'package:ai_amap/ai_amap.dart';
```

## 2.使用

使用'地图'需要动态申请权限,动态权限推荐:[permission_handler](https://github.com/Baseflow/flutter-permission-handler)

配置权限

Android权限配置:

```
<!--
地图SDK(包含其搜索功能)需要的基础权限
-->
<!--允许程序打开网络套接字-->
<uses-permission android:name="android.permission.INTERNET" />
<!--允许程序设置内置sd卡的写权限-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--允许程序获取网络状态-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--允许程序访问WiFi网络信息-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--允许程序读写手机状态和身份-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--允许程序访问CellID或WiFi热点来获取粗略的位置-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
```

iOS权限配置:


```
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Location permission</string>
```

iOS支持PlatformView配置:

```
<key>io.flutter.embedded_views_preview</key>
<true/>
```


### 1.使用'地图'的地方中:

* 1、使用地图

```
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Expanded(
child: AiAMapPlatformWidget(),
),
],
),
),
);
}
```


## LICENSE

BSD 3-Clause License

Copyright (c) 2020, pdliuw
All rights reserved.
138 changes: 137 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,140 @@
|iOS-map|Android-map|
|:-|:-|
|![ios](https://github.com/pdliuw/ai_amap/blob/master/example/gif/ai_amap_ios.gif)|![android](https://github.com/pdliuw/ai_amap/blob/master/example/gif/ai_amap_android.gif)|
|:-|:-|
|:-|:-|


## 1.安装

使用当前包作为依赖库

### 1. 依赖此库

在文件 'pubspec.yaml' 中添加

[![pub package](https://img.shields.io/pub/v/ai_amap.svg)](https://pub.dev/packages/ai_amap)

```
dependencies:
ai_amap: ^version
```

或者以下方式依赖

```
dependencies:
# ai_amap package.
ai_amap:
git:
url: https://github.com/pdliuw/ai_amap.git
```

### 2. 安装此库

你可以通过下面的命令行来安装此库

```
$ flutter pub get
```

你也可以通过项目开发工具通过可视化操作来执行上述步骤

### 3. 导入此库

现在,在你的Dart编辑代码中,你可以使用:

```
import 'package:ai_amap/ai_amap.dart';
```

## 2.使用

使用'地图'需要动态申请权限,动态权限推荐:[permission_handler](https://github.com/Baseflow/flutter-permission-handler)

配置权限

Android权限配置:

```
<!--
地图SDK(包含其搜索功能)需要的基础权限
-->
<!--允许程序打开网络套接字-->
<uses-permission android:name="android.permission.INTERNET" />
<!--允许程序设置内置sd卡的写权限-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--允许程序获取网络状态-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--允许程序访问WiFi网络信息-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--允许程序读写手机状态和身份-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--允许程序访问CellID或WiFi热点来获取粗略的位置-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
```

iOS权限配置:

```
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Location permission</string>
```

iOS支持PlatformView配置:

```
<key>io.flutter.embedded_views_preview</key>
<true/>
```


### 1.使用'地图'的地方中:

* 1、使用地图

```
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Expanded(
child: AiAMapPlatformWidget(),
),
],
),
),
);
}
```


## LICENSE

BSD 3-Clause License

Copyright (c) 2020, pdliuw
All rights reserved.
69 changes: 58 additions & 11 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,63 @@
# ai_amap_example

Demonstrates how to use the ai_amap plugin.
```
## Getting Started
import 'dart:async';
import 'package:ai_amap/ai_amap.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await AiAMapHelper.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Expanded(
child: AiAMapPlatformWidget(),
),
],
),
),
);
}
}
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
```
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>使用定位权限</string>
</dict>
</plist>

0 comments on commit 783648b

Please sign in to comment.