getTabs

書式

getTabs()

説明

タブ付き情報ウィンドウのタブの情報を配列形式で返します。それぞれのタブの情報は各配列要素に入っているので、配列要素を参照することでタブ情報を取得できます。このメソッドはAPI ver 2.59以降で利用できます。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps API2 Sample</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAasAJryKxWJnBFVJa487d9hTHGAxTVT7IRADYa-JdYz7xQ8IQZBSthgDZdggYpQHsmm6WYtHstQFfLA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
window.onload = function() {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37,136), 5,G_NORMAL_MAP);
map.addControl(new GLargeMapControl());
map.addControl(new GScaleControl());
var gpObj = new GLatLng(35,137);
tabList = [
new GInfoWindowTab("タブ1", "サンプル1"),
new GInfoWindowTab("タブ2", "サンプル2"),
]
map.openInfoWindowTabsHtml(gpObj, tabList);
}
function checkTab()
{
var infoWin = map.getInfoWindow();
txt = "タブの総数:"+infoWin.getTabs().length+"<br><br>";
win = infoWin.getTabs()[0];
for(i in win) {
txt += i + " = "+win[i]+"<br>";
}
document.getElementById("result").innerHTML = txt;
}
//]]>
</script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px"></div>
<form>
<input type="button" value="タブ情報取得" onClick="checkTab()">
</form>
<div id="result"></div>
</body>
</html>