diff --git a/zh-cn/react-native-amap-geolocation.md b/zh-cn/react-native-amap-geolocation.md new file mode 100644 index 0000000000000000000000000000000000000000..77b0fa783275668882ee6aa82018ef76f66bde53 --- /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 ( + + + + +