I attempted to get my current location and display in google-maps. for this:
- I activated the Javascript API(in google.developers site).
- got the key to access the api.
- copied the code in the link below to a html file( inserting my key when "calling" the api, of course).
https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
When I ran the html file in the browser, I received an alert giving the error InvalidKeyOrUnauthorizedURL, but it seems that I did everything right, and actually it seems I really did, because when I ran the exact code in the W3Schools tutorials ("Try it your self") the result showed me my location.
So after this context, I would like to know why I can't run this code directly on the browser, I mean, It's kind of OK using the w3schools but it's not the properly way and it's questioning why it's invalid.
observations: note that the file is not being hosted, it is my own computer. I tried to run in Opera and Chrome browser- and they both failed. I ran codes of google maps api successfully directly on the browser but they didn't need any key.
Thanks