Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <select class="country-select" id="country">
  <option value="AU">Australia</option>
  <option value="NZ">New Zealand</option>
<input type="search" class="form-input" id="addrs_1" placeholder="Search address here..."></input>
<div id="map"></div>
              html, body {
  margin: 0;
  font-family: 'Open Sans', Arial, Helvetica, sans-serif;
  font-size: 15px;
  color: #6d6d6d;

#map {
	position: absolute;
	width: 100%;
  margin-top: 10px;
	height: calc(100% - 55px);

#addrs_1 {
  margin-left: 10px;
  margin-top: 10px;
  width: 500px;
  height: 35px;
  font-size: 16px;
  padding-left: 6px;
  box-sizing: border-box;

input[type=search] {
  -webkit-appearance: textfield;
  box-sizing: content-box;

select {
  background-color: white;
  border: thin solid #CCCCCC;
  display: inline-block;
  color: #757575;
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  height: 35px;
  padding: 0.4em 4.5em 0.5em 6px;

  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
} {
    linear-gradient(45deg, transparent 50%, #757575 50%),
    linear-gradient(135deg, #757575 50%, transparent 50%),
    linear-gradient(to right, #CCCCCC, #CCCCCC);
    calc(100% - 20px) calc(1em),
    calc(100% - 15px) calc(1em),
    calc(100% - 2.5em) 0.4em;
    5px 5px,
    5px 5px,
    1px 1.5em;
  background-repeat: no-repeat;
  margin-left: 10px;
  var addressField = d.getElementById('addrs_1'),
      countrySelect = d.getElementById('country'),
      AFAPIkeys = {
      widgets = {
        AU: null,
        NZ: null
      map = null,
      infoWindow = null,
      marker = null;

  function initAF(){
    widgets['AU'] = new AddressFinder.Widget(
    scrollToLocationOnMap(widgets['AU'], 'AU')
    widgets['NZ'] = new AddressFinder.Widget(
    scrollToLocationOnMap(widgets['NZ'], 'NZ')

    setWidgetState(); // Set the initial state for the form
    countrySelect.addEventListener('change', setWidgetState);
  function disableWidgets() {
  function setWidgetState(){
    disableWidgets(); // disable both widgets first
    var countryCode = countrySelect.options[countrySelect.selectedIndex].getAttribute('value'); 
    if (countryCode) {
      // selectively enable the right widget

  function initMap() {
    var myLatLng = getGoogleLatLng(-29.7014833, 144.1768874),
    mapOptions = {
      zoom: 5,
      center: myLatLng,
    map = new google.maps.Map(document.getElementById('map'), mapOptions);
  function scrollToLocationOnMap(widget, countryCode) {
    widget.on('result:select', function(fullAddress, metaData) {
      if (marker) {marker.setMap(null);} // Remove multiple markers
      // latitude is present in AU widget but is named 'y' in NZ widget
      var googleLatLng = metaData.latitude ? getGoogleLatLng(metaData.latitude, metaData.longitude) : getGoogleLatLng(metaData.y, metaData.x)
      // full_address is present in AU widget but full address in NZ widget is available at 'a'
      var address = metaData.full_address ? metaData.full_address : metaData.a
      infoWindow = new google.maps.InfoWindow({
        content: address,
        maxWidth: 300
      marker = new google.maps.Marker({
        position: googleLatLng,
        map: map
      // Make it open by default, marker);
  function addEventListeners() {
    // Allows you to reopen the window if you click on the marker again
    google.maps.event.addListener(marker, 'click', function() { map, marker );
  function getGoogleLatLng(lat, lng) {
    return new google.maps.LatLng(lat, lng)
  function initialise() {
  function addAF() {
    var script = document.createElement('script');
    script.src = '';
    script.async = true;
    script.onload = initialise;
  function addGMaps(){
    var script = document.createElement('script');
    script.src = '';
    script.async = true;
    script.onload = addAF;

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.