LoginSignup
1
2

More than 3 years have passed since last update.

gmaps4railsのマップタイプを設定する

Last updated at Posted at 2019-11-28

はじめに

Google Map APIを利用したアプリ開発をしています。
その時に、マップの表示のデフォルトを航空写真にしたかったので実装してみました。
マップの表示の種類のことをマップタイプと呼ぶそうです。

コード

このようになりました。


<script>
  handler = Gmaps.build('Google');
  handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
    markers = handler.addMarkers(<%= raw @hash.to_json %>);
    handler.bounds.extendWith(markers);
    handler.fitMapToBounds();

    // マップタイプの追記
    handler.getMap().setMapTypeId("satellite");

  });
</script>

参考

参考にしたのはこちら

gmap4railsの設定の変更に役立った
gmaps4railsの地図の拡大率を設定する

mapTypeIdというものがあることを知った
Google Maps API の使い方・利用方法

Mapクラスのメソッド一覧

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2