`navigator.geolocation.getCurrentPosition()` gets stuck and doesn't fire callbacks in Chrome.

落花浮王杯 提交于 2020-03-03 07:56:09

问题


In the depths of an application I need to use the Geolocation API.

    var that = this;

    if(Modernizr.geolocation){
      $(this).addClass("loading");

      navigator.geolocation.getCurrentPosition(function(position){
        that.handleGeoSuccess(position); // defined elsewhere
      },function(error){
        that.handleGeoError(error); // defined elsewhere
      }, {maxAge: 0, timeout: 1000});
    } else {
      that.handleGeoError(); // defined elsewhere
    }

This happens inside of a click-event. Chrome (25.0.1364.155) prompts for permission but none of the callbacks are fired, neither when accepting nor when denying geolocation information. Even asking again using setTimeout didn't work. No callbacks are fired.

I'm quite stuck here and don't know where to look. Any ideas?

btw it works in Firefox (19.0)and Safari (6.0.2), current Chrome Canary behaves the same.

来源:https://stackoverflow.com/questions/15253066/navigator-geolocation-getcurrentposition-gets-stuck-and-doesnt-fire-callbac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!