Circle: strokePosition
strokePositionはCircleクラスのオプションです。円の線の位置を調整します。
値
StrokePosition
線の位置の種類を表すStrokePosition定数を指定する。
- google.maps.StrokePosition.CENTER
- 線は中央に寄せられる。値は
0
。 - google.maps.StrokePosition.INSIDE
- 線は内側に寄せられる。値は
1
。 - google.maps.StrokePosition.OUTSIDE
- 線は外側に寄せられる。値は
2
。
var opts = {
strokePosition: google.maps.StrokePosition.INSIDE ,
} ;
デモ
strokePositionを指定したデモです。分かりやすく、線を太めにしました。内側、中央、外側と、線の位置を調整できるのを確認しましょう。
カスタム
var circle = new google.maps.Circle( {
map: map ,
center: map.getCenter() ,
radius: 8000 ,
strokeWeight: 36 ,
strokeOpacity: 0.5 ,
strokeColor: "red" ,
fillOpacity: 0.25 ,
strokePosition: google.maps.StrokePosition.INSIDE ,
} ) ;
デフォルト
var circle = new google.maps.Circle( {
map: map ,
center: map.getCenter() ,
radius: 8000 ,
} ) ;
サンプルコード
<!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 ,
} ) ;
// Circle
var circle = new google.maps.Circle( {
map: map ,
center: new google.maps.LatLng( 35, 139 ) ,
radius: 8000 ,
strokeWeight: 36 ,
strokeOpacity: 0.5 ,
strokeColor: "red" ,
fillOpacity: 0.25 ,
strokePosition: google.maps.StrokePosition.INSIDE ,
} ) ;
// fit bounds
map.getBounds( circle.getBounds() ) ;
</script>
</body>
</html>