react-native-amap-geolocation icon indicating copy to clipboard operation
react-native-amap-geolocation copied to clipboard

ios下没有返回逆编码信息

Open tivjoe opened this issue 5 years ago • 10 comments

定位没有返回逆编码信息,设置了 setLocatingWithReGeocode(true)和setNeedAddress(true);

tivjoe avatar May 23 '19 14:05 tivjoe

先确定返回的坐标是不是国内的

qiuxiang avatar May 24 '19 03:05 qiuxiang

返回的坐标是国内的,使用Geolocation.getCurrentPosition,返回一次坐标,没有返回逆编码信息。使用watchPosition,第一次返回4次坐标信息,后2次有逆编码信息。但是需求是单次定位,在需要的时候获得一次定位信息,倾向于使用Geolocation.getCurrentPosition,但是没有返回逆编码信息,有什么解决方案吗?

tivjoe avatar May 24 '19 09:05 tivjoe

我之前设置了setLocatingWithReGeocode(true),然后有了code信息,然后这几天也没有了

Wodezhishi321 avatar May 27 '19 07:05 Wodezhishi321

我很确定之前是有逆地理编码信息的,坐标也在国内,现在又没有了

Wodezhishi321 avatar May 27 '19 07:05 Wodezhishi321

貌似是持续定位的前几次获取不到之后能取到

Wodezhishi321 avatar May 27 '19 07:05 Wodezhishi321

单次调用确实不一定能获取到逆地理编码

qiuxiang avatar May 27 '19 08:05 qiuxiang

我这就获取到一次逆地理编码,怎么解决呢,急急急,确定是中国坐标

loveleiforever avatar Jul 27 '19 00:07 loveleiforever

目前我的解决方案是,先设置setLocatingWithReGeocode(true),然后调用Geolocation .watchPosition(),然后调用Geolocation.clearWatch() 结束监听。这样使用Geolocation.getCurrentPosition就能拿到你地址信息了。

Yieron avatar Sep 04 '19 08:09 Yieron

目前我的解决方案是,先设置setLocatingWithReGeocode(true),然后调用Geolocation .watchPosition(),然后调用Geolocation.clearWatch() 结束监听。这样使用Geolocation.getCurrentPosition就能拿到你地址信息了。

实测取不到地址信息,很奇怪。在调试模式下,我开启了hotloading 保存下代码后自动刷新就能拿到了,但正常调用是无论如何都拿不到的

tvsj avatar Feb 23 '21 03:02 tvsj

经过各种尝试,已经发现问题,是init方法异步执行导致的。将init放到应用初始化时执行,而不是每次用到定位都执行一次初始化,就能正常获取地理位置信息了

tvsj avatar Feb 23 '21 07:02 tvsj