Javascript navigator.geolocation不工作

Javascript navigator.geolocation不工作,javascript,ionic2,Javascript,Ionic2,我正在开发一个需要获取用户位置信息的应用程序,我正在使用navigator.geolocation服务来相应地检索用户的纬度和经度。下面是我必须检索他们信息的代码 let options = {maximumAge: 0, timeout: 5000, enableHighAccuracy: true}; navigator.geolocation.getCurrentPosition(function(position){ console.log(position); console

我正在开发一个需要获取用户位置信息的应用程序,我正在使用
navigator.geolocation
服务来相应地检索用户的纬度和经度。下面是我必须检索他们信息的代码

let options = {maximumAge: 0, timeout: 5000, enableHighAccuracy: true};

navigator.geolocation.getCurrentPosition(function(position){
  console.log(position);
  console.log(navigator.geolocation);
}, function(error){console.log(error.message)});

console.log(navigator.geolocation);
然而,我在下面一直遇到这个错误

“”处的网络位置提供程序:返回错误代码403


我检查以确保我的浏览器(我使用的是Chrome)支持
navigator.geolocation
服务,它甚至在控制台中记录了该对象,它可以工作,并且证明它不是浏览器问题。谷歌是否强制某些机器退出其API存储库?我太迷路了

对控制台的快速检查表明,此API将仅在安全地址上工作,因此禁止您使用

getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features for more details.
undefined
VM2552:4 Only secure origins are allowed (see: https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features) 

你的代码没有生成错误报告。我应该声明我在这个应用程序中使用了ionic 2,它与typescript绑定,typescript将解释变量的let关键字。然而,我试着为爱奥尼亚2使用内置的地理定位服务,我遇到了同样的问题,啊,我明白了。。我应该说我使用的是爱奥尼亚2,我正在开发一款移动应用程序。我尝试在爱奥尼亚使用内置的地理定位服务,但我遇到了同样的问题。