InvalidValueError: not an instance of HTMLInputElement
This has been my problem while following the tutorial on Google.
The problem is that you should execute the javascript after the page loads, you can call the function on the GET
parameter while calling the Google Map script:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places$callback=YourFunctionHere"></script>
YourFunctionHere
is a callback function means it will only execute after the page loads.
Or you can can call functions after the page loads. Example: window.onload = Yourfunction();
Now, inside that function is where you would do your Google Maps API stuff like document.getElementById('source_map')
and all methods that belong to the google
class.
Your field is TEXTAREA
, and from last updates, google maps autocomplete now supports only window.HTMLInputElement (INPUT tag)
.
This is an issue of DOM. Your javascript loads before loading your html document.
Make sure your html elements load first and then only load javascript.
Like
and then
Your javascript code