Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="container">
  <h1 class="page-title">Google Geocode to Form</h1>
  <div class="dummy-container">
    <div class="form-group" id="address-mini-form">
      <label for="delivery_address">Delivery Address</label>
      <input type="text" class="form-control autocomplete-address" id="delivery_address" />
      <span class="help-block">Can't find your address? <a href="#address-full-form" data-show-fullform>Try full form</a></span>

    <div id="address-full-form" style="display:none;">
      <div class="form-group">
        <label for="bill_address">Street Address</label>
        <input type="text" class="form-control" id="bill_address" name="bill_address" />
      <div class="form-group">
        <label for="bill_suburb">Suburb</label>
        <input type="text" class="form-control" id="bill_suburb" name="bill_suburb" />
      <div class="form-group">
        <label for="bill_postcode">Postcode</label>
        <input type="text" class="form-control" id="bill_postcode" name="bill_postcode" />
      <div class="form-group">
        <label for="bill_state">State</label>
        <input type="text" class="form-control" id="bill_state" name="bill_state" />
      <div class="form-group">
        <label for="bill_country">Country</label>
        <input type="text" class="form-control" id="bill_country" name="bill_country" />

<script src=""
        async defer></script>


                body {
  background: #3F51B5;
  font-family: 'Roboto', Helvetica, Arial;
  padding: 50px 0;
  .page-title {
    color: #fff;
  .form-control {
    border-radius: 0;
    border-width: 2px;
    box-shadow: none;
    padding: 8px 12px;
    height: auto;
    &:focus {
      outline: none;
      box-shadow: none;
      border-color: #3F51B5;

.dummy-container {
  background: #fff;
  border-bottom: 3px solid #ddd;
  border-radius: 10px;
  box-shadow: 5px 0 15px rgba(0,0,0,0.2);
  padding: 45px 50px;
  margin: 30px 0;

// This is Google Map Autocomplete
.pac-container {
  .pac-item {
    padding: 7px 15px;

    .pac-icon {
      display: none;


                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 to geographical
  // location types.
  autocomplete = new google.maps.places.Autocomplete(
      /** @type {!HTMLInputElement} */(document.getElementById('delivery_address')), {
    types: ['address'],
    componentRestrictions: {country: 'au'}

  // When the user selects an address from the dropdown, 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 fill the corresponding field on the form.
  var fetched_address = [];
  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]];
      fetched_address[addressType] = val;
  // Prefill
  var combined_address = "";
  if(typeof(fetched_address['street_number']) != "undefined") {
    combined_address = fetched_address['street_number'];
  if(typeof(fetched_address['route']) != "undefined") {
    if(combined_address != "") {
      combined_address += " ";
    combined_address += fetched_address['route'];
  var $addressform = $('#address-mini-form');
  $addressform.addClass('has-success has-feedback');
  if(!$addressform.find('.form-control-feedback').length) {
    $addressform.append('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>');

$(function() {
  var geolocate = function() {
    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
  $('.container').on('focus', '#delivery_address', function(e) {
  $('#address-mini-form input').on('keyup', function(e) {
    var $this = $(this), 
        $parent = $this.parents('#address-mini-form');
    $parent.removeClass('has-success has-feedback');
  $('[data-show-fullform]').click(function (e) {
    var $target = $($(this).attr('href'));