title: How to trigger place_changed event for Google places auto-complete on page load
body: <p>I am using google map api where I am filling location from query string on page load but it open select list to select it manually(screen: <a href="http://prnt.sc/exg338" rel="nofollow noreferrer">http://prnt.sc/exg338</a>).
  I just want to trigger place_changed event on pageload after setting message_city's value (from query string) so that the other function can call (which calls after manually selection of location)</p>
  
  <pre><code>geocoder = new google.maps.Geocoder();
  
  cityac = new google.maps.places.Autocomplete( (document.getElementById('message_city')), { types: ['geocode'], componentRestrictions: {country:"GB"} });
  
  google.maps.event.addListener(cityac, 'place_changed', function() { city_select(); });
  
  function city_select() {
          var city = jQuery("#message_city").val();
  
          var place = cityac.getPlace();
          if ((place.address_components[1].short_name == 'London') || (jQuery('#message_city').val() == 'London, United Kingdom')) {
              jQuery('#result_info').val('&lt;br /&gt;London Not Covered ');
              jQuery('#result').val('no');
          } else {
              geocoder.geocode({'address': city}, function (results, status) {
                  if (status == google.maps.GeocoderStatus.OK) {
                      var search = results[0].geometry.location;
                      var mindist = parseInt(10000);
                      var closest = 0;
                      var town = '';
  
                      for (var i = 0; i &lt; locations.length; i++) {
                          var exp = locations[i].split('#');
                          var loc = new google.maps.LatLng(exp[1], exp[2])
                          var distance = calcDistance(loc, search);
                          var miles = parseInt((distance * 0.621371192).toFixed(2));
  
                          if (mindist &gt; miles) {
                              mindist = miles;
                              closest = i;
                              nohour = exp[3];
                              town = exp[0];
                              radius = exp[5];
  
                              if (radius == '') {
                                  radius = 30;
                              }
                              else {
                                  radius = parseInt(radius);
                              }
                          }
  
                      }
                      if (mindist &lt;= radius) {
                          jQuery('#result_info').val('Closest Location is ' + town + ' | ' + mindist + ' miles');
                          jQuery('#result_city').val(town);
                          jQuery('#result').val('yes');
  
                          if (nohour == '1') {
                              //alert('This location has a minimum 2 hour time');
                              jQuery("#serviceHrs option[value='1']").remove();
                              jQuery("#serviceHrs").parent().after("&lt;div class='infomsg' style='color:#ff0099;margin-bottom: 0;'&gt;This location has a minimum of 2 hours.&lt;/div&gt;");
                          }
                          else if (nohour == '0') {
                              jQuery(".infomsg").remove();
                              if (jQuery("#serviceHrs option:contains('1')").length == 0) {
                                  jQuery("#serviceHrs").prepend(new Option("1 Hour", "1"));
                              }
                          }
                      } else {
                          jQuery('#result_info').val('&lt;br /&gt;Closest Location is ' + town + ' | ' + mindist + ' miles, outside the ' + radius + ' mile zone of any current.');
                          jQuery('#result').val('no');
                      }
                  }
              })
          }
      }
  </code></pre>
  
  <p>I am trying below code but it is not working fine.</p>
  
  <pre><code>google.maps.event.trigger(cityac, 'place_changed');
  </code></pre>