【发布时间】:2018-08-27 15:07:38
【问题描述】:
您好,我正在使用以下代码来获取准确的当前纬度和经度 但我无法获得准确的位置,所以任何人都可以建议我如何在 react native(Android 和 iOS)中获得准确的当前纬度和经度。
this.watchID = navigator.geolocation.getCurrentPosition(
(position) => {
console.log(position);
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
error: null,
});
},
(error) => this.setState({ error: error.message }),
// { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
);
}
提前致谢。
【问题讨论】:
标签: android ios reactjs react-native native