GroundOverlay: map
mapはGroundOverlayクラスのオプションです。オーバーレイを設置する地図を指定します。
値
Map
地図を表すMapクラスのインスタンス。
var opts = {
map: map ,
} ;
デモ
mapを指定しない場合、オーバーレイのインスタンスが作成されるだけで、地図にレンダリングされません。
カスタム
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 )
), {
map: map ,
} ) ;
デフォルト
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 )
), {} ) ;
サンプルコード
<!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/map/overlay.svg",
new google.maps.LatLngBounds(
new google.maps.LatLng( 35.708194 , 139.808565 ) ,
new google.maps.LatLng( 35.712280 , 139.813619 )
), {
map: map ,
}
) ;
// fit bounds
map.fitBounds( groundOverlay.getBounds() ) ;
</script>
</body>
</html>