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

定位控件中address为“null”时不抛出错误 #194

Open
zwr19971110 opened this issue Sep 9, 2021 · 6 comments
Open

定位控件中address为“null”时不抛出错误 #194

zwr19971110 opened this issue Sep 9, 2021 · 6 comments

Comments

@zwr19971110
Copy link

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
Copy link
Member

@zwr19971110 提供实例,不清楚你什么问题。

@zwr19971110
Copy link
Author

就是点击定位按钮,showAddressBar不是展示位置吗?就报错address为null,定位也没成功,但是没执行onLocationError

@dream2023
Copy link

dream2023 commented Sep 20, 2021

我遇到了,而且是百分之百复现,具体表现如下:
1

复现步骤如下:

  • 使用定位小组件;
  • 用户首次定位(可以用隐身默认模拟)
  • 点击定位,不就就会报错
  • 再次点击即可获取。

期望

在报错时,能触发 onLocationError 的回调(目前没有),或者重新请求一次(我实验的是,重点一次就可以了,不知道重新请求一次会不会好)。

@jaywcjlove
Copy link
Member

@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
Copy link

应该是百度自身 SDK 有问题,我看是内部报错

@dream2023
Copy link

API 版本改成 v2 就可以 100% 成功了,看样还是 v3 不行

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

3 participants