定位控件中address为“null”时不抛出错误
zwr19971110 opened this issue · 6 comments
zwr19971110 commented
VM12345:1 Uncaught TypeError: Cannot read property 'address' of null
at Geolocation.eval (eval at g_ (getscript?v=3.0&ak=SN5ZPOlev6PEveQvRWhKzR7bIp6q06dM&services=&t=20210830150006:1), :1:778)
at c (eval at g_ (getscript?v=3.0&ak=SN5ZPOlev6PEveQvRWhKzR7bIp6q06dM&services=&t=20210830150006:1), :1:1789)
at eval (eval at g_ (getscript?v=3.0&ak=SN5ZPOlev6PEveQvRWhKzR7bIp6q06dM&services=&t=20210830150006:1), :1:2566)
jaywcjlove commented
@zwr19971110 提供实例,不清楚你什么问题。
zwr19971110 commented
就是点击定位按钮,showAddressBar不是展示位置吗?就报错address为null,定位也没成功,但是没执行onLocationError
dream2023 commented
jaywcjlove commented
@zwr19971110 我不太确认是不是百度 SDK的自身的问题。
我使 SDK 的官方例子,点击都没有反应。
// 添加定位事件
locationControl.addEventListener("locationSuccess", function(e){
var address = '';
address += e.addressComponent.province;
address += e.addressComponent.city;
address += e.addressComponent.district;
address += e.addressComponent.street;
address += e.addressComponent.streetNumber;
alert("当前定位地址为:" + address);
});
locationControl.addEventListener("locationError",function(e){
alert(e.message);
});
dream2023 commented
应该是百度自身 SDK 有问题,我看是内部报错
dream2023 commented
API 版本改成 v2 就可以 100% 成功了,看样还是 v3 不行