地図領域

実行結果

次の例では、ボタンを押した際に地図領域の大きさと表示位置を変更します。

Your borwser is not supporting object tag. Please use one of the latest browsers.
Go to ./apisample/map/map_015.html

ソースコードと解説

地図領域の変更を反映するには、ZDC.Mapクラスのrefresh()を利用します。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<script src="http://api.its-mo.com/cgi/loader.cgi?key=JSZ752c40ded32d&ver=2.0&api=zdcmap.js&enc=EUC&force=1" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
    var map;

    function loadMap() {
        var lat = 35.6778614, lon = 139.7703167;
        map = new ZDC.Map(
            document.getElementById('ZMap'),
            {
                latlon: new ZDC.LatLon(lat, lon),
                zoom: 3
            }
        );
    };

    /* 指定した大きさと位置に地図を表示する */
    function refresh() {
        /* 地図のプロパティを変更 */
        document.getElementById('ZMap').style.top = Number(document.getElementById('t').value) + 'px';
        document.getElementById('ZMap').style.left = Number(document.getElementById('l').value) + 'px';
        document.getElementById('ZMap').style.width = Number(document.getElementById('w').value) + 'px';
        document.getElementById('ZMap').style.height = Number(document.getElementById('h').value) + 'px';

        /* 対応して地図を取得 */
        map.refresh();
    };
//]]>
</script>
</head>

<body onload="loadMap();">
    <div id="ZMap" style="border:1px solid #777777; width:500px; height:300px; top:0px; left:20px; position:absolute;"></div>
    <div id="IBox" style="top:0px; left:540px; position:absolute;">
        top:<input type="text" id="t" size="5" value="0"><br>
        left:<input type="text" id="l" size="5" value="100"><br>
        width:<input type="text" id="w" size="5" value="400"><br>
        height:<input type="text" id="h" size="5" value="300"><br>
        <input type="button" value="refresh" onclick="refresh();">
    </div>
</body>
</html>