From 3acee9aadd0a9babc847f734bfa1b1a524d78038 Mon Sep 17 00:00:00 2001 From: meimei0321 Date: Thu, 13 Jun 2024 17:04:58 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#IA58CL]=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9react-native-amap-geolocation=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meimei0321 --- zh-cn/react-native-amap-geolocation.md | 394 +++++++++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 zh-cn/react-native-amap-geolocation.md diff --git a/zh-cn/react-native-amap-geolocation.md b/zh-cn/react-native-amap-geolocation.md new file mode 100644 index 00000000..77b0fa78 --- /dev/null +++ b/zh-cn/react-native-amap-geolocation.md @@ -0,0 +1,394 @@ +> 模板版本:v0.2.2 + +

+

react-native-amap-geolocation

+

+

+ + Supported platforms + + + License + + +

+ + +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-amap-geolocation) + + + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-amap-geolocation Releases](https://github.com/react-native-oh-library/react-native-amap-geolocation/releases),并下载适用版本的 tgz 包。 + +进入到工程目录并输入以下命令: + +> [!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-amap-geolocation@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-amap-geolocation@file:# +``` + + + +下面的代码展示了这个库的基本使用场景: + +```js +import * as React from "react"; +import { + Button, + Platform, + ScrollView, + StyleSheet, + Text, + View, +} from "react-native"; +import Geolocation from "@react-native-oh-tpl/react-native-amap-geolocation/src/index"; + +const style = StyleSheet.create({ + body: { + padding: 16, + paddingTop: Platform.OS === "ios" ? 48 : 16, + }, + controls: { + flexWrap: "wrap", + alignItems: "flex-start", + flexDirection: "row", + marginBottom: 16, + }, + button: { + flexDirection: "column", + marginRight: 8, + marginBottom: 8, + marginTop:50 + }, + result: { + fontFamily: Platform.OS === "ios" ? "menlo" : "monospace", + }, +}); + +class AmapGeoLocationDemo extends React.Component { + state = { location: null }; + + + componentDidMount(){ + Geolocation.init("aabbbcccc") + } + + +start=()=>{ + console.log("geolocation start"); + Geolocation.start() +}; +stop =()=>{ + console.log("geolocation stop"); + Geolocation.stop(); +} + + onceLocation= ()=>{ + Geolocation.setOnceLocation().then((result)=>{ + let location = result; + this.setState({ location }); + console.log("geolocation onceLocation:"+location); + }).catch((error)=>{ + console.log(error); + }); + + +}; +getLastKnownLocation= () =>{ + Geolocation.getLastKnownLocation().then((result)=>{ + let location = result; + this.setState({ location }); + console.log("geolocation lastLocation:"+location); + }).catch((error)=>{ + console.log(error); + }); +} + + startUpdateLocation= () =>{ + Geolocation.startUpdatingLocation().then((result)=>{ + let location = result; + this.setState({ location }); + console.log("geolocationupdateLocation:"+location); + }).catch((error)=>{ + console.log(error); + }); + +} +stopUpdatingLocation=()=>{ + Geolocation.stopUpdatingLocation(); +} +setInterval10000 = ()=>{ + Geolocation.setInterval(10000); +} +setInterval2000 = ()=>{ + Geolocation.setInterval(2000); +} +setNeedAddressTrue=()=>{ + Geolocation.setNeedAddress(true); +} +setNeedAddressFalse =()=>{ + Geolocation.setNeedAddress(false); +} + +setLangeChinese=()=>{ + // default = 0,chinese = 1, engilish=2; + Geolocation.setGeoLanguage(1); +} +setLangeEnglish=()=>{ + // default = 0,chinese = 1, engilish=2; + Geolocation.setGeoLanguage(2); +} +render() { + const { location } = this.state; + return ( + + + + +