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

Rectangle: fillOpacity

fillOpacityはRectangleクラスのオプションです。レクタングルの塗りつぶしの不透明度を調整できます。

number

スタイルシートと同じ方法で、不透明度を数値で指定する。

var opts = {
	fillOpacity: 1 ,
} ;

デモ

fillOpacityを指定したデモです。

カスタム

var rectangle = new google.maps.Rectangle( {
	map: map ,
	bounds: new google.maps.LatLngBounds(
		new google.maps.LatLng( 32.6868, 132.2624 ) ,
		new google.maps.LatLng( 34.4353, 134.7123 )
	) ,
	fillOpacity: 1 ,
} ) ;

デフォルト

var rectangle = new google.maps.Rectangle( {
	map: map ,
	bounds: new google.maps.LatLngBounds(
		new google.maps.LatLng( 32.6868, 132.2624 ) ,
		new google.maps.LatLng( 34.4353, 134.7123 )
	) ,
} ) ;

サンプルコード

<!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: 15 ,
} ) ;

// Rectangle
var rectangle = new google.maps.Rectangle( {
	map: map ,
	bounds: new google.maps.LatLngBounds(
		new google.maps.LatLng( 32.6868, 132.2624 ) ,
		new google.maps.LatLng( 34.4353, 134.7123 )
	) ,
	fillOpacity: 1 ,
} ) ;

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

デモページを開く

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