Marker: position
positionはMarkerクラスのオプションです。マーカーを設置する位置座標を調整できます。
値
LatLng
位置座標を表すLatLngクラスを指定する。
var opts = {
position: new google.maps.LatLng( 35, 139 ) ,
} ;
デモ
positionを指定したデモです。指定した位置座標にマーカーが設置されます。
var marker = new google.maps.Marker( {
map: map ,
position: new google.maps.LatLng( 35, 139 ) ,
} ) ;
map.setCenter( marker.getPosition() ) ;
サンプルコード
<!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 ,
} ) ;
// Marker
var marker = new google.maps.Marker( {
map: map ,
position: new google.maps.LatLng( 35, 139 ) ,
} ) ;
// set center
map.setCenter( marker.getPosition() ) ;
</script>
</body>
</html>