Chrome navigator.geolocation.getCurrentPosition() error 403

前端 未结 3 743
借酒劲吻你
借酒劲吻你 2020-12-09 14:59

For some reason suddenly when calling navigator.geolocation.getCurrentPosition() I get this error:

Network location provider at \'https://www.goog

3条回答
  •  既然无缘
    2020-12-09 15:18

    This happens for me too on idoco.github.io/map-chat

    I suspect that this is related the the changes google planed for Deprecating Powerful Features on Insecure Origins it seems that some changes were done in the last few days in this chromium Issue 520765: Deprecation and removal of powerful features on insecure origins

    Can you test your site over https to confirm that?

    In the meanwhile I found this api usage as a workaround on this repo:

      $.getJSON("http://ipinfo.io", function(doc){
        var latlong = doc.loc.split(",")
        setUserLocation(parseFloat(latlong[0]), parseFloat(latlong[1]));
        getLocation(parseFloat(latlong[0]), parseFloat(latlong[1])).then(function(res){
          userLocationName = res
        })
        initialiseEventBus();
        map.panTo(userLocation);
    
      }, function(err) {
        setUserLocation(Math.random()*50, Math.random()*60);
        userLocationName = "unknown.na"
        initialiseEventBus();
        map.panTo(userLocation);
      })
    

提交回复
热议问题