PHP & JavaScript Room :: 設置サンプル

実行結果


ソース

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAvABrzCnRluKK0Cj97fTMThTNR7aHVSEFb0WbViWwc6F-_w9PjBSogZu_7UgOTbx25ka46X-fnGmyvw" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map,obj;
function load() {
    if(GBrowserIsCompatible()){
        /* 地図インスタンス生成 */
        map=new GMap2(document.getElementById("map"));
        /* 中心地点 */
        map.setCenter(new GLatLng(35.658421,139.699069), 17);
        /* 情報ウィンドウ表示 */
        map.openInfoWindowHtml(map.getCenter(), "<p>東京渋谷区にある<a href='http://www.s-markcity.co.jp/'>「マークシティー」</a>です。</p><p><img src='/content/img/ajax/star.png' align='left' alt='' />渋谷駅直結なので雨の日でも便利です。<br>ショッピングやランチどころ満載です。</p>");
         /* イベント */
        document.getElementById("res").value="";
        GEvent.addListener(map, "infowindowopen", function(){
            document.getElementById("res").value+="情報ウィンドウが表示されました\n";
        });
        GEvent.addListener(map, "infowindowbeforeclose", function(){
            document.getElementById("res").value+="情報ウィンドウが閉じられようとしています\n";
        });
        GEvent.addListener(map, "infowindowclose", function(){
            document.getElementById("res").value+="情報ウィンドウが閉じられました\n";
        });
    }
}
function fOpenInfoWindowHtml(){
    /* 情報ウィンドウ表示 */
    map.openInfoWindowHtml(new GLatLng(35.658416,139.69907), "<p>東京渋谷区にある<a href='http://www.s-markcity.co.jp/'>「マークシティー」</a>です。</p><p><img src='/content/img/ajax/star.png' align='left' alt='' />渋谷駅直結なので雨の日でも便利です。<br>ショッピングやランチどころ満載です。</p>");
    document.getElementById("res").value="";
    document.getElementById("btn_open").disabled=true;
    document.getElementById("btn_close").disabled=false;
}
function fCloseInfoWindow(){
    map.closeInfoWindow();
    document.getElementById("btn_open").disabled=false;
    document.getElementById("btn_close").disabled=true;
}
window.onload=load;
window.unload=GUnload;
//]]>
</script>
<div id="map" style="width:425px;height:300px"><!-- 地図描画領域 --></div><br>
<form action="#">
    <p>
        <input type="button" value="情報ウィンドウ表示" onclick="fOpenInfoWindowHtml();" id="btn_open" disabled="disabled" />
        <input type="button" value="情報ウィンドウを閉じる" onclick="fCloseInfoWindow();" id="btn_close" />
    </p>
    <textarea cols="64" rows="3" id="res" style="width:421px;"></textarea>
</form>

polarized women