GroundOverlayOptions
GroundOverlayOptionsは、オーバーレイの設定を調整するためのオブジェクトです。オーバーレイを作成する時のGroundOverlayクラスの引数などに利用できます。
プロパティ
プロパティ名 | 説明 |
---|---|
clickable | boolean trueならクリックが有効、falseなら無効になる。 |
map | 地図を表すMapクラスのインスタンス。 |
opacity | number スタイルシートと同じ方法で、不透明度を表す数値を指定する。 |
デモ
オプションの内容を確認して下さい。ここで紹介し切れなかったプロパティは、専用のページをご参考下さい。
var options = {
map: map ,
clickable: true ,
opacity: 0.5 ,
} ;
var groundOverlay = new google.maps.GroundOverlay(
"./overlay.svg" ,
new google.maps.LatLngBounds(
new google.maps.LatLng( 35.708194, 139.808565 ) ,
new google.maps.LatLng( 35.712280, 139.813619 )
) , options
) ;
サンプルコード
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas {
width: 600px ;
height: 600px ;
}
</style>
</head>
<body>
<div id="map-canvas"></div>
<script src="//maps.googleapis.com/maps/api/js?key={APIキー}"></script>
<script>
var mapDiv = document.getElementById( "map-canvas" ) ;
// Map
var map = new google.maps.Map( mapDiv, {
center: new google.maps.LatLng( 35.71, 139.8107 ) ,
zoom: 11 ,
} ) ;
// GroundOverlay
var options = {
map: map ,
clickable: true ,
opacity: 0.5 ,
} ;
var groundOverlay = new google.maps.GroundOverlay(
"https://lab.syncer.jp/Web/API/Google_Maps/JavaScript/GroundOverlayOptions/overlay.svg" ,
new google.maps.LatLngBounds(
new google.maps.LatLng( 35.708194, 139.808565 ) ,
new google.maps.LatLng( 35.712280, 139.813619 )
) , options
) ;
// fit bounds
map.fitBounds( groundOverlay.getBounds() ) ;
</script>
</body>
</html>
参考
- Google Maps JavaScript API: GroundOverlayOptions
- Googleの公式リファレンス。