I am having a similar issue.
The package that I use to test the code though is the Atom live-web-server by jas-chen.
The following is a screenshot of the file opened up in Atom.
The next screenshot is when I try to run the code in the live web server:
The next screenshot is when I try to run the code in the live web server but pointed to the specific file (location.html) which can be seen in the very first image/screenshot.
The following picture is the result of placing all the code into one file and the code works.
I am aware that one needs to link CSS to HTML and JS to HTML however I am not been able to make the API work when putting the code into different files.
Please help. I am still new to this. The transition from business school to the Hello World!/coding world is is a bit difficult.