Change the value in textbox of a google map autocomplete

后端 未结 4 1464
温柔的废话
温柔的废话 2021-01-05 13:06

I have the following javascript code which does google map autocomplete on different input textboxes that are parts of an address.

function startAutoComplete         


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 14:01

    I've found a very temporary solution. It seems if you purposely create an error it'll unbind the google maps autocomplete from the original text box and reveal your original textboxes with the updated value. Not really a solution but it's a start

    //Created this variable that stores the pac-container
    var element = document.getElementsByClassName("pac-container");
    
    //inside the addListener() function I added this to create a DOM error
    element[0].childNodes[0].childNodes[0].removeChild();
    

    The javascript throws an error but it at least allows me to put in what I want in the textbox using '.value'

    Again not a solution but a start. I hope we find a better solution.

提交回复
热议问题