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

            
              <html>
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="//maps.google.com/maps/api/js?libraries=places&key=AIzaSyAuqtG8XhmKQPGoYpFi9dqZmhZTDWGCxE0"></script>
  </head>
  <body>
    <div class="input-wrapper">
      <form id="input-form">
        <input type="text" name=address" id="address" placeholder="住所を入力してください">
        <input id="address-btn" type="submit" value="検索">
      </form>
                                                      
    </div>
    <div class="map-wrapper">
    <div id="map-canvas" class="map-canvas"></div>
    </div>
  </body>
</html>
            
          
!

CSS

            
              body {
  font-size: 14px;
}
input[type="text"] {
  padding: 5px 10px;
  font-size: 14px;
}
input[type="button"] {
  font-size: 14px;
}
.input-wrapper {
  width: 100%;
  margin-bottom: 20px;
}
.map-wrapper {
  width: 100%;
  height: 250px;
}
.map-canvas {
    width: 100%;
    height: 100%;
    margin: 0 auto;
}
            
          
!

JS

            
              $(function() {

  var canvas = document.getElementById('map-canvas');

  var latlng = new google.maps.LatLng(35.681382, 139.766084);

  var mapOptions = {
    zoom: 14,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    scrollwheel: false
  };

  var mapObj = new google.maps.Map(canvas, mapOptions);
  var marker = [];
  var infoWindow = [];

  // マーカーデータ
  var markerData = [
    {
      position: new google.maps.LatLng(35.681382, 139.766484),
      title: '店舗xxx',
      content: '添付コンテンツX',
		  icon: '//drive.google.com/uc?export=view&id=1ir7dzJwVH6gpil5dP1-1fGdfsNPmnrPj',
    },
    {
      position: new google.maps.LatLng(35.681282, 139.779044),
      title: '店舗aaa',
      content: '添付コンテンツA',
		  icon: '//drive.google.com/uc?export=view&id=1ir7dzJwVH6gpil5dP1-1fGdfsNPmnrPj',
    },
    {
      position: new google.maps.LatLng(35.681282, 139.769044),
      title: '店舗bbb',
      content: '添付コンテンツB',
		  icon: '//drive.google.com/uc?export=view&id=1ir7dzJwVH6gpil5dP1-1fGdfsNPmnrPj',
    },
    {
      position: new google.maps.LatLng(35.682382, 139.756084),
      title: '店舗yyy',
      content: '添付コンテンツY',
		  icon: '//drive.google.com/uc?export=view&id=1ir7dzJwVH6gpil5dP1-1fGdfsNPmnrPj',
    }
  ];

  // マーカーの表示
  for (i = 0; i< markerData.length; i++) {
    marker[i] = new google.maps.Marker({
      position: markerData[i].position,
      map: mapObj,
      title: markerData[i].title,
      icon: markerData[i].icon,
    });

    infoWindow[i] = new google.maps.InfoWindow({ // 吹き出しの追加
      content: '<div class="name">' + markerData[i]['title'] + '</div>'
    });
    
    markerEvent(i);
  }
  
  function markerEvent(i) {
    marker[i].addListener('click', function() {
      infoWindow[i].open(mapObj, marker[i]);
    });
  }
  
  $('#input-form').submit(function() {
    setAddress($('#address').val());
    return false;
  });

  // 住所検索
  function setAddress(address) {
	  var sad = address;
	  var geocoder = new google.maps.Geocoder();
	  geocoder.geocode({'address':sad}, function(results, status) {
	  	if (status == google.maps.GeocoderStatus.OK) {
	  		mapObj.setCenter(results[0].geometry.location);
	  	} else {
	  		alert('住所から場所を特定できませんでした。');
	  	}
	  });
  }

});
            
          
!
999px

Console