Local Weather API - issues with navigator.geolocalisation

Hi guys,

Im wondering why the navigator.geolocalisation function didnt provide me the lat and long of my browser.
The code is exacly the same than on FFC lesson, and on the lesson it works, on code pen it didnt.
Anyone could help ?


HTML part :
<div id="data"></div>

JS part :

    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        $("#data").html("latitude: " + position.coords.latitude + 
"<br>longitude: " + position.coords.longitude);

geolocation doesn’t work because you need to use a secure connection ( https ). Trying your code on https://codepen… the browser ask me to allow the geolocalization and if I authorize it your code works.

– Note: this is the message in the chrome console which explain that.
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://goo.gl/rStTGz for more details.

( Sorry for my english :stuck_out_tongue: )

Yes thanks I got it ! :slight_smile: