Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

地图可以显示在北京,但是不能定位,接收到的nativeEvent参数都是undefined #615

Closed
perfecten opened this issue Jun 27, 2020 · 3 comments

Comments

@perfecten
Copy link

1.版本
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-amap-geolocation": "^1.1.2",
"react-native-amap3d": "^2.0.1",

2.设备
iOS,虚拟机,真机

3.问题描述
地图可以显示在北京,但是不能定位,接收到的nativeEvent参数都是undefined

4.代码
<MapView style={{flex:1}}
locationEnabled={true}
onStatusChangeComplete={ ({ nativeEvent }) =>
{
console.log('onStatusChangeComplete',nativeEvent);
}
}
onLocation={({ nativeEvent }) =>
{
console.log('onLocation',nativeEvent);
}
}
>

5.log输出
2020-06-27 19:52:33.004 [info][tid:com.facebook.react.JavaScript] 'onStatusChangeComplete', undefined
2020-06-27 19:52:34.517 [info][tid:com.facebook.react.JavaScript] 'onLocation', undefined

6.补充
AppDelegate文件也根据安装文档,配置了key。

react-native-amap-geolocation可以收到定位数据,证明key是对的。

@perfecten
Copy link
Author

当我把版本降低成1.1.1又可以了,麻烦大神指导。谢谢

"react-native-amap3d": "^1.1.1",

@perfecten
Copy link
Author

今天发先原来是 "^2.0.1"版的接口变了。


onLocation={(nativeEvent ) =>
↑去掉nativeEvent前后的大括号,就是坐标了。

onStatusChangeComplete={ ({ center }) =>
↑要修改成center才是坐标

我可是郁闷了好几天了,才找到问题所在,
如果大神能顺便把说明也修改了就好了,谢谢。

@qiuxiang
Copy link
Owner

现在有接口文档,比如这里 https://qiuxiang.github.io/react-native-amap3d/api/interfaces/mapviewprops.html

还有如果你的编辑器支持 ts 补全的话,也会有相应提示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants