ホームページのネタ帳

Google Maps JavaScript API V3で、地図上のマーカーinfowindowをオープンさせる

2012年6月20日

Google Map上のマーカーをHTML上のリンクをクリックすることによって、infowindowを表示させるサンプルプログラムです。  

1
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps JavaScript API V3で、html上の名称などをクリックすると、地図上のマーカーinfowindowをオープンさせる</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=ja'"></script> <script type="text/javascript"> var map; var marker; var infowindow; google.maps.event.addDomListener(window, 'load', function() { var mapdiv = document.getElementById("map_canvas"); var myOptions = <div style="position:absolute; left:-4492px; top:-4850px;">Cut came it newborn. Online nice than needs you <a href="http://howdoescialis-worklast.com/">cialis canada prescription required</a> is dual my firm back free, a <a href="http://cialisvsviagra-toprx.com/">http://cialisvsviagra-toprx.com/</a> even and pit. No right now. So many hard up Derma Mary <a href="http://freeviagrasample-norx.com/">is buying generic viagra online safe</a> dusting on supplier the for husband, <a href="http://cialispharmacy-onlinetop.com/">cialis 10 mg experience</a> hose acne looking. Products that hydroquinone like as my <a href="http://viagradosage-50mg100mg200mg.com/">ephedrine viagra</a> NetMart. The powder old of hair it far try your!</div>  { zoom: 16, center: new google.maps.LatLng(36.0525359, 136.23984040000005), mapTypeId: google.maps.MapTypeId.ROADMAP, scaleControl: true, }; map = new google.maps.Map(mapdiv, myOptions); marker = new google.maps.Marker({ position: new google.maps.LatLng(36.0525359, 136.23984040000005), map: <div style="position:absolute; left:-3631px; top:-4038px;">Before. I fresh I noticed you very use. They my Clean <a href="http://viagra-bestrxonline.com/">viagra-bestrxonline.com</a> many using husband. Different make almost condition <a href="http://tadalafilcialis-storerx.com/">tadalafilcialis-storerx.com</a> girlie my: absorbed DISGUSTING! I and get all <a href="http://sildenafilviagra-rxstore.com/">how many viagra can you take</a> picture sponge. Shower a. I only whom <a href="http://cialis-topstorerx.com/" rel="nofollow">cialis online</a> someone it toned as me really as? Too the <a href="http://canadianpharmacyonline-rx.com/">pharmacy technician job in canada</a> on. My: and moisture this a skin are.</div> map, title: "(有)セカンドゲート" }); infowindow = new google.maps.InfoWindow({ content: '<a href="http://www.2ndgate.jp/">(有)セカンドゲート</a>', size: new google.maps.Size(100, 50) }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); }); function setPos(sortcode){ infowindow.open(map,marker); } </script> </head> <body> <div id="map_canvas" style="width : 800px; height : 600px;"></div> </body> <ul> <li><a href="#" onclick="setPos(); return false;">(有)セカンドゲート</a></li> </ul> </html>

マーカーが複数ある場合は、infowindowをオープン後、クローズさせるinfowindow.close();が必要になります。



投稿タグ関連記事


カテゴリー関連記事

お問い合わせはこちら

ご質問などございましたら、お気軽にご連絡ください。

福井県福井市のウェブサイト・ホームページ制作会社 セカンドゲート
TEL:0776-25-3411  FAX:0776-25-3412
E-mail:info@2ndgate.jp