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

Rectangle: editable

editableはRectangleクラスのオプションです。レクタングルの編集の有効、無効を調整できます。

boolean

trueなら編集が有効、falseなら無効になる。

var opts = {
	editable: true ,
} ;

デモ

editableを指定したデモです。

カスタム

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 )
	) ,
	editable: true ,
} ) ;

デフォルト

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 )
	) ,
	editable: true ,
} ) ;

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

デモページを開く

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