2***@qq.com
2***@qq.com
  • 发布:2022-08-31 11:40
  • 更新:2023-08-23 15:49
  • 阅读:792

急急急!plus.geolocation.getCurrentPosition获取不到address数据

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 3.5.3

手机系统: 全部

打包方式: 离线

App下载地址或H5⽹址: 暂无

测试过的手机:

华为 p40

操作步骤:

plus.geolocation.getCurrentPosition(WhenAddress, function(e) {});
// 获取当前地址
function WhenAddress(position) {

            Lon = position.coords.longitude; //获取经度  
            Lat = position.coords.latitude; //获取纬度  
            var address = '';  
            console.log(JSON.stringify(position));  
            address += !position.address.province ? "" : position.address.province;  
            address += !position.address.city ? "" : "," + position.address.city;  
            address += !position.address.district ? "" : "," + position.address.district;  
        }

预期结果:

可以正常使用

实际结果:

报错:TypeError: Cannot read property 'province' of undefined

bug描述:

升级最新版本,HBuilder X 3.5.3 后,使用
plus.geolocation.getCurrentPosition 获取不到address。
版本降级后 HBuilderX.2.7.14 后 正常使用。

我怎么处理一下 在最新版本可以正常使用呢?

2022-08-31 11:40 负责人:无 分享
已邀请:
CODE_XU

CODE_XU

这是我用 iPhone6 测试获取的地址

{  
    "coordsType": "wgs84",  
    "address": {  
        "city": "北京市",  
        "country": "中国",  
        "district": "海淀区",  
        "street": "西直门北大街辅路"  
    },  
    "addresses": "西直门北大街辅路",  
    "coords": {  
        "latitude": 39.95068372335992,  
        "longitude": 116.348901491607,  
        "accuracy": 65,  
        "altitude": 54.22509765625,  
        "heading": null,  
        "speed": null,  
        "altitudeAccuracy": 10  
    },  
    "timestamp": 1661917398677.122  
}
2***@qq.com

2***@qq.com (作者) - 介绍一下

我用最新的HBuilder X 3.5.3
手机 iphone xr :
打印的数据:{"coordsType":"wgs84","address":{"city":"济南市","country":"中国","district":"槐荫区","province":"山东省","street":"齐州路","streetNum":"106号"},"addresses":"齐州路106号","coords":{"latitude":36.68052455041013,"longitude":116.8938524060198,"accuracy":65,"altitude":29.16618728637695,"heading":null,"speed":null,"altitudeAccuracy":10},"timestamp":1661922049293.933}
华为 p40:
打印的数据:{"coordsType":"wgs84","coords":{"latitude":36.680837,"longitude":116.89551,"accuracy":22.492844,"altitude":0,"heading":null,"speed":0,"altitudeAccuracy":0},"timestamp":null}

y_j_x

y_j_x

我也遇到这个问题,怎么处理

要回复问题请先登录注册