ポリラインがクリックできないようにする

説明

ポリラインがクリックできないようにするにはgoogle.maps.Polyline()でのオプションパラメータのclickableにfalseを指定します。デフォルトではtrueになっておりクリックできるようになっています。

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 myPath = new google.maps.Polyline({
path: [
new google.maps.LatLng(35.689160610317174, 139.70083951950073),
new google.maps.LatLng(37.689160610317174, 139.70083951950073),
new google.maps.LatLng(36.689160610317174, 138.70083951950073)
],
strokeWeight: 20,
clickable: false
});
myPath.setMap(map);
google.maps.event.addListener(myPath, "click", function() {
alert("ポリラインがクリックされました");
});
</script>
</body>
</html>