# location_plugin
**Repository Path**: zxh91989/location_plugin
## Basic Information
- **Project Name**: location_plugin
- **Description**: flutter 定位
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-04-09
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Amap Location Plugin
[](https://pub.dartlang.org/packages/amap_location_plugin)
A Flutter plugin to access location information with AMap Location SDK.
This plugin now is only developed for Android platform, so it only inplements the android amap sdk.
which provides the function with location infomation for flutter app in android platform in china.
According to the usage description below, developer can get the location infomation easily.

## Usage
To use this plugin, add `amap_location_plugin` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
### 1.依赖高德地图定位sdk
在app的build.gradle文件里加入
```
dependencies {
implementation 'com.amap.api:location:latest.integration'
}
```
在flutter的pubspec.yaml文件里添加
```
dependencies:
flutter:
sdk: flutter
...
amap_location_plugin: ^0.1.1
```
### 2.申请key
根据[高德官方文档](https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key)申请高德sdk的key
### 3.配置AndroidManifest.xml
在AndroidManifest.xml的application标签中配置Key:
```xml
```
在application标签中声明service组件:
```xml
```
在AndroidManifest.xml中按需配置权限:
```xml
```
### Example
``` dart
// Import package
import 'package:amap_location/amap_location_plugin.dart';
// Instantiate it
AmapLocation _amapLocation = AmapLocation();
//start location
_amapLocation.startLocation;
//stop location
_amapLocation.stopLocation;
// Access current location
print(_amapLocation.getLocation);
// Be informed when the state (full, charging, discharging) changes
_amapLocation.onLocationChanged.listen((String location) {
// Do something with new state
});
```