最初からマーカー上に情報ウィンドウ(ふきだし)を表示する

説明

最初からマーカー上に情報ウィンドウ(ふきだし)を表示するにはnew google.maps.Marker()でマーカーオブジェクトを生成します。次にnew google.maps.InfoWindow()として新たにウィンドウを生成します。マーカーオブジェクトを生成した後に、ウィンドウオブジェクトのopen()メソッドを使って表示を行います。
Google Maps APIプログラミング入門 Google Maps API プログラミング入門。Google Maps API Expertである勝又雅史氏が最新のAPI ver3やGoogle Maps for Flashなどについて解説しています。
アマゾンで購入する

サンプルコード [実行]

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Google Maps API ver 3 Sample/グーグルマップAPIサンプル/Google Maps API样品</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="gmap"></div>
<script type="text/javascript">
var map = new google.maps.Map(
document.getElementById("gmap"),{
zoom : 7,
center : new google.maps.LatLng(35.689160610317174, 139.70083951950073),
mapTypeId : google.maps.MapTypeId.ROADMAP
}
);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(35.689160610317174, 139.70083951950073),
map: map
});
var infowindow = new google.maps.InfoWindow({
content: "最初からウィンドウが表示されます"
});
infowindow.open(map, marker);
</script>
</body>
</html>