Why is access denied for location?

I am using google chrome and the location setting is set to all websites can access your location, but I still get a access denied error. Here is the codepen: http://codepen.io/roman_fedoruk/pen/pNoLvr
If anyone knows how to fix this it would be greatly appreciated.

You can use an IP to location API from your errorHandler, this way you can get the users’ location even if you can’t get it by using the geolocation.getCurrentPosition().


I’ve just notice that I didn’t answer your question. So, the reason it is not working in Chrome is that they no longer support the geolocation API on non-secure sites. If you access CodePen with https://, it should work. However, users can deny access to geolocation, so an IP to location API as a second option is more reliable.

Chrome console gives getCurrentPosition() and watchPosition() no longer work on insecure origins. It works at https://your-pen.

1 Like

@zsoltime Thanks! that works now!

@Velenir Thanks, it works now!