I am trying to get the coords from the browser, then set them in the this.longitude but I am getting the error geolocation.js:13 Uncaught TypeError: Cannot read property 'coords' of undefined at Geolocation.setCurrentPosition (geolocation.js:13) at main.js:39
I am not sure how to fix this issue. Any guidance so that I can better learn would be greatly appreciated!
What @skaparate says (needs to be HTTPS, it’s protected for security reasons). But also it’s async, so afaics (you’ve a slightly strange setup, so I may be misreading something here) there isn’t a property coords because it won’t have acquired the object by the time you try to access it.
I tested the code and it works, but there is an issue: the second parameter to getCurrentPosition should be a reference to a function, not the call to it. In other words, remove the parenthesis and reference it using this.
Another problem you may be having is that the location can only be accessed using https: