I want to use geolocation and direction function, but there is google is not defined error. the code is as below:
function loadScript() {
I tried it on my own with this code - it worked fine for me
Dynamic with key
Static without key
...
...
When surfing through the net I tumbled over an important note!
Google Maps JavaScript API v3
The Google Maps JavaScript API v3 does not require an API key to function correctly. However, we strongly encourage you to load the Maps API using an APIs Console key which allows you to monitor your application's Maps API usage. Learn how to use an APIs Console key.
See Google Maps API
So, apparently you no longer need a developer key! I tried it with both - static no key and dynamnic with key - both worked.