Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geolocation Without SSL connection

Tags:

I am developing an application which uses geolocation coordinates. I used the HTML5 geolocation feature to find out the location of the site visitor, but the issue is with Chrome which doesnt support GeoLocation on insecure origins.

  function showPosition(){     if(navigator.geolocation){         navigator.geolocation.getCurrentPosition(function(position){             var positionInfo = "Your current position is (" + "Latitude: " + position.coords.latitude + ", " + "Longitude: " + position.coords.longitude + ")";             document.getElementById("result").innerHTML = positionInfo;         });     } else{         alert("Sorry, your browser does not support HTML5 geolocation.");     } } 

Here is the code getCurrentPosition is not working in as my site is not SSL connected .

Warning by Chrome : 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.

Is there any other way to get coordinates/LatLong values on chrome ? [on Insecure connection only]

EDIT : It is working in my machine using localhost:80 but not working in test url which is on http

like image 475
Niranth Reddy Avatar asked Sep 07 '16 09:09

Niranth Reddy


1 Answers

Really simple: open Chrome, open this address and enter the domains you wish to enable for

chrome://flags/#unsafely-treat-insecure-origin-as-secure 

enter image description here

This way it's permanent and you don't need to open the chrome browser each time with

google-chrome  --args --unsafely-treat-insecure-origin-as-secure="http://whatever.test"` 

as answered above.

like image 162
Aryeh Beitz Avatar answered Oct 14 '22 13:10

Aryeh Beitz