Well I had assumed it would be a case of copy and paste somethings

<div id="page-wrapper">
	<div class="content-control">
		<div class="heading-control"><h3>Shop details</h3></div>
			<div class="control-contain">
			<form method="POST" class="control-style" id="login">		
				<div class="form-control">
					<input type="text" name="shopname" placeholder="Shop name">
				</div>
				<div class="form-control">
					 <input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text"/>
				</div>
				<div class="form-control">
					<input type="text" class="field" id="street_number" disabled="true" placeholder="Enter your address here"/>
				</div>
				<div class="form-control">
					<input type="text" class="field" id="route" disabled="true" placeholder="Street name"/>
				</div>
				<div class="form-control">
					<input type="text" class="field" id="locality" disabled="true" placeholder="City"/>
				</div>
				<div class="form-control">
					<input type="text" class="field" id="administrative_area_level_1" disabled="true" placeholder="Region"/>
				</div>
				<div class="form-control">
					<input type="text" class="field" id="postal_code" disabled="true" placeholder="Postcode"/>
				</div>	</div>
	
			
		
			<div class="form-control">
                   <input type="submit" name="search" id="search" value="Update details">
            </div>  
			 <span class="success"> </span>	
		</form>			


<script>
// This sample uses the Autocomplete widget to help the user select a
// place, then it retrieves the address components associated with that
// place, and then it populates the form fields with those details.
// This sample requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script
// src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">

var placeSearch, autocomplete;

var componentForm = {
  street_number: 'short_name',
  route: 'long_name',
  locality: 'long_name',
  administrative_area_level_1: 'short_name',
  country: 'long_name',
  postal_code: 'short_name'
};

function initAutocomplete() {
  // Create the autocomplete object, restricting the search predictions to
  // geographical location types.
  autocomplete = new google.maps.places.Autocomplete(
      document.getElementById('autocomplete'), {types: ['geocode']});

  // Avoid paying for data that you don't need by restricting the set of
  // place fields that are returned to just the address components.
  autocomplete.setFields('address_components');

  // When the user selects an address from the drop-down, populate the
  // address fields in the form.
  autocomplete.addListener('place_changed', fillInAddress);
}

function fillInAddress() {
  // Get the place details from the autocomplete object.
  var place = autocomplete.getPlace();

  for (var component in componentForm) {
    document.getElementById(component).value = '';
    document.getElementById(component).disabled = false;
  }

  // Get each component of the address from the place details,
  // and then fill-in the corresponding field on the form.
  for (var i = 0; i < place.address_components.length; i++) {
    var addressType = place.address_components[i].types[0];
    if (componentForm[addressType]) {
      var val = place.address_components[i][componentForm[addressType]];
      document.getElementById(addressType).value = val;
    }
  }
}

// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
function geolocate() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var geolocation = {
        lat: position.coords.latitude,
        lng: position.coords.longitude
      };
      var circle = new google.maps.Circle(
          {center: geolocation, radius: position.coords.accuracy});
      autocomplete.setBounds(circle.getBounds());
    });
  }
}
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBkwj8LzaJif45S5r4rUkOp0o8ddI-c11A&libraries=places&callback=initAutocomplete"
        async defer></script>			
			</div>
	</div>
</div>

Error

InvalidValueError: setFields: not an Array

    So, setFields is a function that takes an array argument?

    If so ...

    autocomplete.setFields(['address_components']);

    I kinda got it working needs some styles now

    Also where is resolve now?...

      Write a Reply...