In my case, the problem was that I opened the HTML file from the file system ( file:///... ). Browsers usually try to prevent access to personal information (including location) from local files, so you should serve the file through a web server (even if it is local).
One easy way to serve a static website located on your file system is SimpleHTTPServer if you have Python installed. Just browse to the folder using the command line and say python -m SimpleHTTPServer and then you can view the file on localhost:8000 .
source share