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.

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.

HTML

              
                <div class="wrapper">
  <div id="js-map" class="map"></div>
</div>
              
            
!

CSS

              
                /* 初期化用 */
html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
.wrapper {
  width: 100%;
  height: 100%;
}

/* マップ用のCSS */
.map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 350px;
  overflow: hidden;
}
              
            
!

JS

              
                // 位置情報取得が成功したら
let success = (pos) => {
  // マップオブジェクトの変数を空で宣言
  let map;
  let myLocation;

  // マップオプションを変数に格納
  let mapOptions = {
    zoom: 14, // 拡大率
    center: { // 中心座標を指定
      lat: 35.6811673, // 緯度
      lng: 139.7648629 // 経度
    }
  };

  // マップオブジェクト作成
  map = new google.maps.Map(
    document.getElementById('js-map'),
    mapOptions
  );

  // マップにマーカーを表示する
  myLocation = new google.maps.Marker({
    map: map, // mapに対して指定(マップオブジェクト作成したやつ)
    position: mapOptions.center, // mapOptionsから座標を指定
    icon: {
      url: 'https://higemura.com/wordpress/wp-content/uploads/2018/10/ic_gmap_mylocation.svg', // icon画像(png画像でも可)
      scaledSize: new google.maps.Size(32, 32) // 表示するアイコンサイズ
    },
    title: '現在地' // アイコンにマウスホバーすると出てくる文言
  });
}

// 位置情報取得が失敗したら
let error = (err) => {
  // エラーメッセージ
  msg = 'エラーが発生しました: ' + err;
  console.log(msg);
}

// 位置情報を取得
navigator.geolocation.getCurrentPosition(success, error);
              
            
!
999px

Console