Currently Iām trying to use one of my fields in a custom module to be autocompleted with the Google Places API, Iāve been able to do an example on my localhost with just a textbox and it works just fine before trying to transfer the code over to my custom javascript.
Iāve added my
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places&key=AIzaSyAvWClrsdpl2pYkkxTKu_DaYMYLYpGuVcA"></script>
into my editviewdefs.php in the javascript include and inspect element shows that this is loading, and Iāve added my custom js into my script
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
let input = document.getElementById('o_address_c');
new google.maps.places.Autocomplete(input);
}
but on my test server the textbox is autofilled with āEnter a locationā and the autocomplete works fine - in suitecrm nothing happens and I get the āgoogle is not definedā error. Iāve tried using both async, defer, and find that both break the local code and doesnāt change anything in suitecrm. Looking at the HTML of the page when it loads shows the google API script being called before my custom script so it should be defined. Is there a way I can call a script before editviewdefs.php is called? I see that the google API is connected to in requests but Iām unable to troubleshoot this