cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
  <title>Google Maps Multiple Markers</title> 
  <script src="https://maps.google.com/maps/api/js?sensor=false"></script>
</head> 
<body>
  <div class=row>
    <h2>The Heroes</h2>
    <p>
      <!-- >
      <span style="background-color: #ffcdd2">
      Supporter / 5 USD 
      </span> 
      &nbsp;&nbsp;&nbsp;&nbsp;
      <span style="background-color: #FFCC80">
      Hero / 10 USD
      </span> 
      &nbsp;&nbsp;&nbsp;&nbsp;
      <span style="background-color: #E6EE9C">
      Contributor / 25 USD
        </span>
      &nbsp;&nbsp;&nbsp;&nbsp;
        </br>
  <span style="background-color: #80DEEA">
      Champion / 50 USD
    </span>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <span style="background-color: #64B5F6">
      Star / 100 USD
    </span>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <span style="background-color: #0e7feb"> 
      All star / 200 USD
    </span>
  -->
      Click the spots to see the Backers
    </br>
    </p>  
  </div>
  
  <div class="row text-center centered">
    <div id="map"></div>
  </div>
  
  <div class=row>
    <p>This is footer<p>
  </div>
  
  </body>
  </html>
            
          
!
            
              body{
  text-align: center;
  margin: auto;
}

#map{
  /*width: 500px;*/ 
  height: 450px;
}

.centered{
  display: block;
  margin: auto;
  width: 90%;
}
            
          
!
            
              // Define your locations: HTML content for the info window, latitude, longitude
    var locations = [
      ['<h4>Obama</h4><img src="http://pngimg.com/upload/face_PNG5660.png" height="100" width="100">', -33.890542, 151.274856],
      ['<h4>Jared Leto</h4><img src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTczMjUwNDUzMF5BMl5BanBnXkFtZTgwNDA4OTAzMTE@._V1_UY1200_CR85,0,630,1200_AL_.jpg" height="100" width="100">', -33.923036, 151.259052],
      ['<h4>Amanda Palmer</h4><img src="http://amandapalmer.net/wp-content/uploads/2013/09/1173818_10151647707218375_1357447411_n-300x200.png" height="100" width="100">', 40.6451594,-74.0850828],
      ['<h4>Random Girl</h4><img src="https://s-media-cache-ak0.pinimg.com/originals/62/71/76/627176b115aee264d92f7a33df1137d9.jpg" height="100" width="100">', -33.80010128657071, 151.28747820854187],
      ['<h4>Old Man</h4><img src="https://cdn.pixabay.com/photo/2014/05/22/16/57/face-351281_960_720.jpg" height="100" width="100">', -33.950198, 101.259302],
      ['<h4>RadioHead </h4> <img src="http://i1.kym-cdn.com/entries/icons/original/000/018/291/radiohead.jpg" height="100" width="100">', 30.950198, 131.259302],
       ['<h4>Oview </h4> <img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRnD3tNAqzahr3RHZvGa5m-REBWzbt6lijC0fRA2wxfS0tHJUvvpA" height="100" width="100">', 52.3105386,4.7],
      ['<h4> Smile</h4><img src="https://s-media-cache-ak0.pinimg.com/736x/e6/80/51/e680511993fbd24b5e922c0fb4b377b2.jpg" height="100" width="100">', -23.950198, 151.259302]
    ];
    
    // Setup the different icons and shadows
    var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/';
    
    var icons = [
      iconURLPrefix + 'red-dot.png',
      iconURLPrefix + 'green-dot.png',
      iconURLPrefix + 'blue-dot.png',
      iconURLPrefix + 'orange-dot.png',
      iconURLPrefix + 'purple-dot.png',
      iconURLPrefix + 'pink-dot.png',      
      iconURLPrefix + 'yellow-dot.png'
    ]
    var iconsLength = icons.length;

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 2,
      center: new google.maps.LatLng(38.219139, -171.521267),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      mapTypeControl: false, /* option for satelate view*/
      streetViewControl: false,
      panControl: false,
      zoomControlOptions: {
         position: google.maps.ControlPosition.LEFT_BOTTOM
      }
    });

    var infowindow = new google.maps.InfoWindow({
      maxWidth: 205
    });

    var markers = new Array();
    
    var iconCounter = 0;
    
    // Add the markers and infowindows to the map
    for (var i = 0; i < locations.length; i++) {  
      var marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map,
        icon: icons[iconCounter]
      });

      markers.push(marker);

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
      
      iconCounter++;
      // We only have a limited number of possible icon colors, so we may have to restart the counter
      if(iconCounter >= iconsLength) {
      	iconCounter = 0;
      }
    }

    function autoCenter() {
      //  Create a new viewpoint bound
      var bounds = new google.maps.LatLngBounds();
      //  Go through each...
      for (var i = 0; i < markers.length; i++) {  
				bounds.extend(markers[i].position);
      }
      //  Fit these bounds to the map
      map.fitBounds(bounds);
    }
    autoCenter();
            
          
!
999px
🕑 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.
Loading ..................

Console