Why is access denied for location?

Why is access denied for location?
0

#1

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.


#2

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().

Edit:

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.


#3

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


#4

@zsoltime Thanks! that works now!


#5

@Velenir Thanks, it works now!