# react-native-yunpeng-amplocation **Repository Path**: m2mbob/react-native-yunpeng-amplocation ## Basic Information - **Project Name**: react-native-yunpeng-amplocation - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-07-25 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # react-native-yunpeng-amplocation support basic location and background locating ## Getting started ### Mostly automatic install 1. `npm install rnpm --global` 2. `npm install react-native-yunpeng-amplocation --save` 3. `rnpm link react-native-yunpeng-amplocation` ### Manual install #### Android 1. `npm install react-native-yunpeng-amplocation --save` 2. Open up `android/app/src/main/java/[...]/MainActivity.java` - Add `import com.yunpeng.amaplocation.YPAmapLocationPackage;` to the imports at the top of the file - Add `new YPAmapLocationPackage()` to the list returned by the `getPackages()` method 3. Append the following lines to `android/settings.gradle`: ``` include ':react-native-yunpeng-amaplocation' project(':react-native-yunpeng-amaplocation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-yunpeng-amaplocation/android') ``` 4. Insert the following lines inside the dependencies block in `android/app/build.gradle`: ``` compile project(':react-native-yunpeng-amaplocation') ``` 5. add android permission ``` ``` 6. add amap key in application ``` ``` ## Usage 1. configure ``` componentWillMount() { YPAmapLocation.configure({ notificationTitle: "xxx", notificationText: "xxx!", notificationIconColor: "#ccc", startForeground: true, interval: 5000, url: api.location, httpHeaders: { 'Accept': 'application/json', 'Content-Type': 'application/json', // TODO 更新authdata 'Authorization': 'Basic ' + rest.authdata } }).then((result) => { if(result){ console.log('configure success!'); } }) } ``` 2. location ``` YPAmapLocation.getCurrentPosition({}) .then((position) => { self.setState({region: position.coords}); }, (err) => { console.log(err); }) ``` 3. background Observing ``` // start YPAmapLocation.startObserving() .then(() => { console.log('start observing success'); }); // stop YPAmapLocation.stopObserving(); ```