SYNCERのロゴ
アイキャッチ画像

GroundOverlay: clickable

clickableはGroundOverlayクラスのオプションです。オーバーレイのクリックの有効、無効を調整します。

boolean

trueならクリックが有効、falseなら無効になる。

var opts = {
	clickable: false ,
} ;

デモ

clickableを指定したデモです。オーバーレイにホバーした時のマウスカーソルの形状の変化で、有効、無効を確認して下さい。

カスタム

var groundOverlay = new google.maps.GroundOverlay( "./overlay.png", new google.maps.LatLngBounds(
	new google.maps.LatLng( 35.708194 , 139.808565 ) ,
	new google.maps.LatLng( 35.712280 , 139.813619 )
), {
	clickable: true ,
} ) ;

デフォルト

var groundOverlay = new google.maps.GroundOverlay( "./overlay.png", new google.maps.LatLngBounds(
	new google.maps.LatLng( 35.708194 , 139.808565 ) ,
	new google.maps.LatLng( 35.712280 , 139.813619 )
), {} ) ;

サンプルコード

<!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, 139 ) ,
	zoom: 11 ,
} ) ;

// GroundOverlay
var groundOverlay = new google.maps.GroundOverlay(
	"https://lab.syncer.jp/Web/API/Google_Maps/JavaScript/GroundOverlay/clickable/overlay.svg" ,
	new google.maps.LatLngBounds(
		new google.maps.LatLng( 35.708194, 139.808565 ) ,
		new google.maps.LatLng( 35.712280, 139.813619 )
	) , {
		map: map ,
		clickable: false ,
	}
) ;

// fit bounds
map.fitBounds( groundOverlay.getBounds() ) ;
	</script>
</body>
</html>

デモページを開く

  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2015年9月1日 (火)
コンテンツを公開しました。