Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

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.

HTML

            
              <div class="map-container">
  <div id="map"></div>
  <div id="map-overlay"><button id="click-me">Click me</button>
  </div>
</div>
            
          
!

CSS

            
              .map-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

#map {
  height: 100%;
  margin-left: -240px;
  // negative width of overlay + left margin/horizontal position
}

#map:before {
  content: '';
  position: absolute;
  left: 50%;
  border-left: 1px solid lightgreen;
  height: 100%;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

#map:after {
  content: '';
  position: absolute;
  top: 50%;
  border-top: 1px solid lightgreen;
  height: 100%;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

#map-overlay {
  width: 200px;
  position: absolute;
  top: 40px;
  right: 40px;
  bottom: 40px;
  background-color: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 20px;
}

#map {
  .move-google-maps-attr(240px);
}

body,
html {
  width: 100%;
  height: 100%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

// Maps logo and controls
// https://www.google.com/permissions/geoguidelines/attr-guide.html
// https://web.archive.org/web/20160505030052/http://www.google.com/permissions/geoguidelines/attr-guide.html
// The automatically generated Google logo and data provider attribution may only be removed or obstructed if reintroduced in a visible form elsewhere within the Content (e.g. photo caption below a Google Earth still). In other words, your text must be as visible as it would have been if you had used the default text that we provide.
// .gm-style:first-child is standard map view
//  1 : map
//  2 : google logo
//  3 : map-data window
//  4 : map data
//  5 : map data (noscreen)
//  6 : terms of use
//  7 : full screen
//  8 : report map error
//  9 : map controls
// 10 : map type controls
.move-google-maps-attr(@a_horizontal) {
  > .gm-style:first-child {
    > div {
      margin-left: -(@a_horizontal) !important;
      margin-right: @a_horizontal !important;
    }
    > div:first-child,
    > div:nth-child(3),
    > div:nth-child(9),
    > div:nth-child(10) {
      margin-left: 0 !important;
      margin-right: 0 !important;
    }
    > div:nth-child(2) {
      left: @a_horizontal !important;
      margin-left: 5px !important;
      margin-right: 5px !important;
    }
    > div:nth-child(4) {
      width: auto !important;
      > div {
        > div:nth-child(2) {
          > a {
            // Map Data link
            display: inline !important;
          }
          > span {
            // Map data text
            display: none !important;
          }
        }
      }
    }
    > div:nth-child(7),
    > div:nth-child(9) {
      margin-right: 10px + @a_horizontal !important;
      /* +10px; */
    }
    > div:nth-child(10) {
      margin-left: 10px + @a_horizontal !important;
      /* +10px; */
    }
  }
}
            
          
!

JS

            
              var map;
var latLng = [
  { lat: -25.5695769, lng: 134.5407184 },
  { lat: -25.4695769, lng: 133.5407184 },
  { lat: -25.8695769, lng: 133.7407184 }
];

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    zoom: 8,
    center: latLng[0],
  });
  
  for (var i = 0; i < latLng.length; i++)
    new google.maps.Marker({
      position: latLng[i],
      map: map
    });
}

initMap();

var i = 0;
$('#click-me').click(function() {
  i = ++i % latLng.length;
  console.log(latLng[i])
  map.panTo(latLng[i]);
});
            
          
!
999px

Console