例−14:住所を検索して、その場所を表示する(GGoogleBar)
Google Maps API version 2.92から、GGoogleBar という機能が提供されるようになりました。 これにより、ユーザーが簡単に地図を検索したりすることが出来るようになりました。 使うには、GMaps2.enableGoogleBar() メソッドを呼び出すだけです。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps JavaScript API Example</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script src="http://maps.google.co.jp/maps?file=api&v=2&key=[あなたのAPIキー]&sensor=false"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load(){
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(35.676148, 139.74479), 15);
//検索バーを表示する
map.enableGoogleBar();
}
//ページがロードされたら、load 関数を実行して、地図を表示する
window.onload = load;
//ページを抜けるとき、メモリ開放
window.onunload = GUnload;
//]]>
</script>
</head>
<body >
<div id="map" style="width: 600px; height: 600px"></div>
</body>
</html>


