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
Really simple: open Chrome, open this address and enter the domains you wish to enable for
chrome://flags/#unsafely-treat-insecure-origin-as-secure
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With