Map: scaleControlOptions
scaleControlOptionsはMapクラスのオプションです。スケールコントローラのスタイルを調整できます。といっても2017年現在、選択肢はデフォルトの1つしかないため、実質的には意味のないオプションです。
値
ScaleControlOptions
専用のオブジェクトを指定する。利用できるのは、スタイル(style)のみ。
var opts = {
scaleControl: true ,
scaleControlOptions: {
style: google.maps.ScaleControlStyle.DEFAULT ,
} ,
} ;
デモ
2017年現在、指定できるのはデフォルトの値だけなので、指定した場合も指定しない場合も違いはありません。
カスタム
// <div id="map-canvas"></div>
var mapDiv = document.getElementById( "map-canvas" ) ;
var opts = {
center: new google.maps.LatLng( 35.71, 139.8107 ) ,
zoom: 11 ,
scaleControl: true ,
scaleControlOptions: {
style: google.maps.ScaleControlStyle.DEFAULT ,
} ,
} ;
var map = new google.maps.Map( mapDiv, opts ) ;
デフォルト
// <div id="map-canvas"></div>
var mapDiv = document.getElementById( "map-canvas" ) ;
var opts = {
center: new google.maps.LatLng( 35.71, 139.8107 ) ,
zoom: 11 ,
scaleControl: true ,
} ;
var map = new google.maps.Map( mapDiv, opts ) ;
サンプルコード
<!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" ) ;
var opts = {
center: new google.maps.LatLng( 35.71, 139.8107 ) ,
zoom: 11 ,
scaleControl: true ,
scaleControlOptions: {
style: google.maps.ScaleControlStyle.DEFAULT ,
} ,
} ;
var map = new google.maps.Map( mapDiv, opts ) ;
</script>
</body>
</html>