uiwjs / react-native-amap-geolocation Goto Github PK
View Code? Open in Web Editor NEWReact Native 高德地图定位模块,支持 Android/iOS。
Home Page: https://uiwjs.github.io/react-native-amap-geolocation/
License: MIT License
React Native 高德地图定位模块,支持 Android/iOS。
Home Page: https://uiwjs.github.io/react-native-amap-geolocation/
License: MIT License
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
@types/react
, react
, react-test-renderer
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@babel/core
, @babel/preset-env
, @babel/runtime
)@types/jest
, babel-jest
, jest
)com.facebook.flipper:flipper-fresco-plugin
, com.facebook.flipper:flipper-network-plugin
, com.facebook.flipper:flipper
)example/Gemfile
cocoapods '~> 1.11', '>= 1.11.3'
example/ios/Podfile
.github/workflows/ci.yml
actions/checkout v3
actions/setup-node v3
peaceiris/actions-gh-pages v3
ncipollo/release-action v1
android/build.gradle
com.amap.api:location 6.2.0
example/android/gradle.properties
com.facebook.flipper:flipper 0.125.0
com.facebook.flipper:flipper-network-plugin 0.125.0
com.facebook.flipper:flipper-fresco-plugin 0.125.0
example/android/settings.gradle
example/android/build.gradle
com.android.tools.build:gradle 7.3.1
example/android/app/build.gradle
androidx.swiperefreshlayout:swiperefreshlayout 1.0.0
example/android/gradle/wrapper/gradle-wrapper.properties
gradle 7.5.1
example/.node-version
node 18
example/package.json
react 18.2.0
react-native 0.71.4
@babel/core ^7.20.0
@babel/preset-env ^7.20.0
@babel/runtime ^7.20.0
@react-native-community/eslint-config ^3.2.0
@tsconfig/react-native ^2.0.2
@types/jest ^29.2.1
@types/react ^18.0.24
@types/react-test-renderer ^18.0.0
babel-jest ^29.2.1
eslint ^8.19.0
jest ^29.2.1
metro-react-native-babel-preset 0.73.8
prettier ^2.4.1
react-test-renderer 18.2.0
typescript 4.8.4
package.json
react 18.2.0
react-native 0.71.4
typedoc 0.18.0
typescript 4.8.4
react ^16.8.1
react-native >=0.60.0-rc.0 <1.0.x
example/.ruby-version
ruby 2.7.6
import { Platform } from 'react-native';
import AMapGeolocation from '@uiw/react-native-amap-geolocation';
let apiKey = '';
if (Platform.OS === 'ios') {
apiKey = '用于 iOS 的 apiKey';
}
if (Platform.OS === 'android') {
apiKey = '用于 Android 的 apiKey';
}
// 设置 高德地图 apiKey
AMapGeolocation.setApiKey(apiKey);
// iOS 指定所需的精度级别
AMapGeolocation.setDesiredAccuracy(3);
// Android 指定所需的精度级别,可选设置,默认 高精度定位模式
AMapGeolocation.setLocationMode(1);
// 定位是否返回逆地理信息
AMapGeolocation.setLocatingWithReGeocode(true);
async function getCurrentLocation(){
try {
const json = await AMapGeolocation.getCurrentLocation();
console.log('json:', json);
} catch (error) {
console.log('error:', error);
}
}
getCurrentLocation的json 老是null,请问要如何配置
初始化的代码放在 useEffect里,其他地方没有 AMapGeolocation 类的引入和使用。在xcode本地启动后会有如下报错, 但此时app还在lunach阶段, 并且后面定位一直不会获取。
useEffect(() => {
amapLocationListener(user);
}, [])
// 高德地图持续定位
function amapLocationListener(user) {
let apiKey = ""
if (Platform.OS === "ios") {
apiKey = Config.AMAP_KEY_IOS
}
if (Platform.OS === "android") {
apiKey = Config.AMAP_KEY_ANDROID
}
if (apiKey) {
try {
// 设置 高德地图 apiKey
AMapGeolocation.setApiKey(apiKey)
} catch (error) {
console.log("error:", error)
}
}
console.log("apiKey: ", apiKey)
// iOS 指定所需的精度级别
AMapGeolocation.setDesiredAccuracy(3)
// Android 指定所需的精度级别,可选设置,默认 高精度定位模式
AMapGeolocation.setLocationMode(1)
// 定位是否返回逆地理信息, 这里只要定位
AMapGeolocation.setLocatingWithReGeocode(false)
// 定位上报间隔
AMapGeolocation.setInterval(3000)
// 当设备可以正常联网时,还可以返回该定位点的对应的**境内位置信息(包括:省、市、区/县以及详细地址)。
const listener = AMapGeolocation.addLocationListener((location) => {
console.log("返回定位信息", location, user)
locationReport(
{
coords: {
longitude: location.longitude,
latitude: location.latitude,
speed: location.speed,
},
timestamp: location.timestamp,
},
user,
"GCJ-02", // 用高德sdk获取的定位 使用的高德的坐标系
)
})
// 开启监听
AMapGeolocation.start()
return () => {
// 停止更新位置信息
AMapGeolocation.stop()
// 移除监听事件
listener && listener.remove()
}
}
Invariant Violation: new NativeEventEmitter()
requires a non-null argument., js engine: hermes
有支持的计划吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.