I am getting this error on my website which requests Geolocation data from the user:
getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See goo.gl/rStTGz for more details.
I mean its basically just a notice, and the google link just says its being deprecated.
I have no plans on moving my website to SSL... so is there an alternative for someone like me?
You could use the https://ipinfo.io API for this (it's my service). It's free for up to 1,000 req/day (with or without SSL support). It gives you coordinates, name and more. Here's an example:
Here's an example which constructs a coords object with the API response that matches what you get from
getCurrentPosition()
:And here's a detailed example that shows how you can use it as a fallback for
getCurrentPosition()
:See http://ipinfo.io/developers/replacing-navigator-geolocation-getcurrentposition for more details.
Yes. Google Chrome has deprecated the feature in version 50. If you tried to use it in chrome the error is:
getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins for more details.
So, you have to add SSL certificate. Well, that's the only way.
And it's quite easy now using Let's Encrypt. Here's guide
And for testing purpose you could try this:
I think Firefox also restricted user from accessing GeoLocation API requests from
http
. Here's the webkit changelog: https://trac.webkit.org/changeset/200686Found a likely answer in /jstillwell's posts here: https://github.com/stefanocudini/leaflet-gps/issues/15 basically this feature will not be supported (in Chrome only?) in the future, but only for HTTP sites. HTTPS will still be ok, and there are no plans to create an equivalent replacement for HTTP use.