I am trying to add Google place auto suggest, I copied the code from the developer's website to try it out but got the error : google.maps.event.addDomListener() is deprecated, use the standard addEventListener() method instead. Also I am not getting any place suggestions.
https://developers.google.com/maps/documentation/javascript/places-autocomplete
google.maps.event.addDomListener(window, 'load', initializeAutocomplete);
i have also added script
<script src="https://maps.googleapis.com/maps/api/jskey=api_key&libraries=places"></script>
I have implemented the same thing in one html it worked successfully, but when I used it on click button which opens a popup (form which has place-input), it gave me this error.
Note : I have also tried addEventListener but that's giving me an error : google.maps.event.addEventListener is not a function
Do you have any idea why I am getting this error, and how can I fix this?
As addDomListener() is deprecated, use the standard addEventListener() method instead, you can do so as follows:
window.addEventListener('load', initializeAutocomplete)
Replace in a similar fashion at all the required places.
google.maps.event.addDomListener(<OBJECT>,<EVENT>,<FUNCTION>);
to
<OBJECT>.addEventListener(<EVENT>,<FUNCTION>);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With