説明
カスタムオーバーレイはテキストや画像を用意しマップにappendChild()を使って追加し表示を行います。
続きは書籍で、どうぞ...
<!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>Sample</title>
<style type="text/css"><!--
#msg {
position:absolute;
left:200px;
top:150px;
width:200px;
height:100px;
background-color:yellow;
opacity:0.5;
filter:alpha(opacity=50);
border:2px red solid;
}
--></style>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAasAJryKxWJnBFVJa487d9hTHGAxTVT7IRADYa-JdYz7xQ8IQZBSthgDZdggYpQHsmm6WYtHstQFfLA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map, customDiv;
function customBox() { }
customBox.prototype = new GOverlay();
customBox.prototype.initialize = function(map) {
map.getPane(G_MAP_MAP_PANE).appendChild(customDiv);
}
customBox.prototype.redraw = function(force){}
window.onload = function() {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37,136), 5,G_NORMAL_MAP);
customDiv = document.getElementById("msg");
map.addOverlay(new customBox());
}
//]]>
</script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px"></div>
<div id="msg">カスタムオーバーレイのサンプルです</div>
</body>
</html>