如何在本机反应中获得纬度和经度?

Posted

技术标签:

【中文标题】如何在本机反应中获得纬度和经度?【英文标题】:How to get Latitude and Longitude in react native? 【发布时间】:2019-03-07 15:56:09 【问题描述】:

我需要知道如何在本地响应 http 中获取纬度和经度。 示例:

http://example.com/TEST/app.do?do=savestatus&u=user&lat=latitude&lng=longitude...

感谢您的帮助!!!。

【问题讨论】:

【参考方案1】:

如果您正在寻找一种简单的方法来获取您的经纬度,您可以使用 RN 的 navigator API:

const options =  enableHighAccuracy: true ;
const self = this;
navigator.geolocation.getCurrentPosition(success, error, options);
function success(pos) 
    const  latitude, longitude  = pos.coords;
    self.setState( location: `$latitude,$longitude`);

source

【讨论】:

以上是关于如何在本机反应中获得纬度和经度?的主要内容,如果未能解决你的问题,请参考以下文章