5 Replies Latest reply on Mar 7, 2016 6:17 PM by Sanford Whiteman

    Embed Code Not working with Google places API

    Ravi Ansal

      Hi,

       

      I have created a Code to auto complete the Company name using Google Location.

       

      Refer Below but it is not working can you help me with the issue:

       

      <script src="//app-sj04.marketo.com/js/forms2/js/forms2.min.js"></script>

      <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>

      <form id="mktoForm_1627"></form>

      <script>

       

       

      MktoForms2.loadForm("//app-sj04.marketo.com", "023-STC-548", 1627,

       

       

      function(form)

      {

          var formEl = form.getFormElem()[0];

          var companyField = formEl.querySelector('INPUT[name="Company Name"]');

       

          var defaultBounds = new google.maps.LatLngBounds(

            new google.maps.LatLng(-90,-180),

            new google.maps.LatLng(90,180)

          );

         

          var options = {

              bounds: defaultBounds,

              types: ['establishment']

          };

       

       

          autocomplete = new google.maps.places.Autocomplete(companyField, options);

         

          google.maps.event.addListener(autocomplete, 'place_changed', function() {

       

       

              // shorten object to just name

              acCompanyName = autocomplete.getPlace().name;

              companyField.value = acCompanyName;   

             

              // just for fun, fill website too

              acWebsite = autocomplete.getPlace().website;

              if (acWebsite) websiteField.value = acWebsite;  

       

       

        });   

      });       

      </script>

       

      and also what is difference between Field and name in Marketo?

       

      Message was edited by: Ravi Ansal