/******************************************************************************** SYNCER 〜 知識、感動をみんなと同期(Sync)するブログ * 配布場所 https://syncer.jp/google-maps-javascript-api-matome * 最終更新日時 2015/08/06 13:12 * 作者 あらゆ ** 連絡先 Twitter: https://twitter.com/arayutw Facebook: https://www.facebook.com/arayutw Google+: https://plus.google.com/114918692417332410369/ E-mail: info@syncer.jp ※ バグ、不具合の報告、提案、ご要望など、お待ちしております。 ※ 申し訳ありませんが、ご利用者様、個々の環境における問題はサポートしていません。 ********************************************************************************/ // キャンパスの要素を取得する var canvas = document.getElementById( 'map-canvas' ) ; // 中心の位置座標を指定する var latlng = new google.maps.LatLng( 35.794361,139.791421 ); // 地図のオプションを設定する var mapOptions = { zoom: 18 , // ズーム値 center: latlng , // 中心座標 [latlng] }; // [canvas]に、[mapOptions]の内容の、地図のインスタンス([map])を作成する var map = new google.maps.Map( canvas , mapOptions ) ; // 矩形領域のインスタンスを格納する配列 var rectangles = [] ; // 左下(南西)と右上(北東)の2つの位置座標(LatLngクラス)を作成 var sw = new google.maps.LatLng( 35.70762360182525 , 139.80627971954345 ) ; var ne = new google.maps.LatLng( 35.71218849512444 , 139.8149700767517 ) ; // 2つのLatLngクラスを引数にして、LatLngBoundsクラスを作成 var latlngBounds = new google.maps.LatLngBounds( sw , ne ) ; // 矩形領域のオプション var rectangleOption = { bounds: latlngBounds , //南西と北東の位置座標をLatLngBoundsクラスで指定 map: map , //設置する地図キャンパス } ; // 矩形領域のインスタンスを作成する rectangles[0] = new google.maps.Rectangle( rectangleOption ) ; // ビューポートの調整 map.fitBounds( latlngBounds ) ;