This is not strictly an issue with this code, but an issue with the website you link to as an example.
The website shows a popup that says:
You have to allow the website to know your location
The Chrome DevTools window shows the following message:
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. See https://goo.gl/rStTGz for more details.
It is free (and very easy) to get a certificate from LetsEncrypt.org.