例−24:線(ライン)を引くサンプル2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>例−24:線(ライン)を引くサンプル2</title>
<script src="http://maps.google.co.jp/maps?file=api&v=2&key=ABQIAAAA98lY54ryNP9it66EDNJo7xTGK3r1MPnJ5e6s0Bz065WpOCHpoRQPU_yRUcFTKJyFF1fLqgYcXItTsw"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var lines=[];
var map;
function makeLine(points){
line = new GPolyline(points, "#FF0000", 10);
return line;
}
function draw(lat1, lng1, lat2, lng2){
var p1=new GLatLng(lat1, lng1);
var p2=new GLatLng(lat2, lng2);
//ラインを描画
var points=[];
points[0]=p1;
points[1]=p2;
var line = makeLine(points);
lines.push(line);
map.addOverlay(line);
}
function erase(){
if(lines.length==0){return;}
//ラインを消去
var line=lines.shift();
map.removeOverlay(line);
}
function load(){
map = new GMap2( document.getElementById("map"));
map.setCenter( new GLatLng(35.684, 139.750), 14 );
}
GEvent.addDomListener(window, "load", load);
GEvent.addDomListener(window, "unload", GUnload);
//]]>
</script>
</head>
<body >
<h1>例−24:線(ライン)を引くサンプル2</h1>
<div id="map" style="width:600px;height:600px;">
</body>
</html>




