Is a secure ssl connection required for the geographic location of google map?

I am using google map geo location api. I first tested it on a local, working file on both firefox and chrome. When he moved it to the site (i.e. not https), it works fine for firefox, but doesn't work on chrome. Getting this error:

Geocoding error

Here is my code:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">
    var geocoder;

    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
    }
    //Get the latitude and the longitude;
    function successFunction(position) {
        var lat = position.coords.latitude;
        var lng = position.coords.longitude;
    }

    function errorFunction() {
        alert("Geocoder failed");
    }
</script>

Does chrome need a secure ssl connection for geolocation?

+4
source share
1 answer

For Chrome version> = 50, the geolocation API requires a secure origin. But it should work well on your localhost.

- , (, , ):

  • (https, *, *)
  • (wss, *, *)
  • (*, localhost, *)
  • (*, 127/8, *)
  • (*,:: 1/128, *)
  • (, *, -)
  • (chrome-extension, *, -)

.

: Firefox, iOS Safari, Chrome Android Samsung Internet .

+5

All Articles