我使用的是html5地理定位 我根据文档制作
getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.showPosition, this.showError);
} else {
alert("geolocation not support");
}
},
如果我使用 Chrome(toogle 设备工具栏),代码可以正常工作 但在移动浏览器 chrome(android) safari(ios) 中显示错误
User did not share location
如何解决?
在手机上启用地理定位
UPD: Most likely this is due to the fact that there is no ssl certificate ?
最佳答案
并非所有浏览器都内置相同的 API。因此,您必须弄清楚客户端正在使用什么浏览器,并根据包含的 API 编写不同的代码。您可以通过检查用户代理来了解他们使用的浏览器。
关于javascript - 如何在移动网络浏览器中访问地理位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43615553/