緯度経度

実行結果

次の例では、ボタンを押した際に吹き出しを表示し、その緯度経度を地図の中心点にします。

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

ソースコードと解説

吹き出しを表示するには、ZDC.MsgInfoクラスを利用します。
指定した緯度経度を地図の中心点にするには、ZDC.MapクラスのmoveLatLon()を利用します。
ただし、ZDC.MapクラスのmoveLatLon()ZDC.MsgInfoクラスのopen()より前に実行してください。

<!DOCTYPE html>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<script src="//api.its-mo.com/v3/webgl-loader?key=JSZddc5111626c8|Zo4wz&ver=bldg_w_tex&api=webgl.js&enc=EUC&force=1" type="text/javascript"></script>
<script type="text/javascript">
    "use strict";
    var map, msg, latlon = new ZDC.LatLon(35.6611861, 139.7631861);

    function loadMap() {
        map = new ZDC.Map(
            document.getElementById('ZMap'),
            {
                latlon: new ZDC.LatLon(35.66297325982054, 139.76598186955528),
                zoom: 14.5,
                heading: 155,
                tilt: 70
            }
        );

        /* スケールバーを作成 */
        var scale = new ZDC.ScaleBar();

        /* スケールバーを表示 */
        map.addWidget(scale);

        /* 中心点画像を作成 */
        map.addWidget(new ZDC.MapCenter());

        /* マーカを作成 */
        map.addWidget(new ZDC.Marker(latlon));

        /* 吹き出しを作成 */
        msg = new ZDC.MsgInfo(latlon, {
            html: 'Zetメンズ館',
            offset: ZDC.Pixel(0, -18)
        });

        /* 吹き出しを追加 */
        map.addWidget(msg);
    };

    /* 吹き出しを表示 */
    function openMsginfo() {
        /* ZDC.MapクラスのmoveLatLon()をZDC.MsgInfoクラスのopen()より前に実行 */
        map.moveLatLon(latlon);
        msg.open();
    };

</script>
</head>

<body onload="loadMap();">
    <div id="ZMap" style="border:1px solid #777777; width:750px; height:500px; top:0px; left:20px; position:absolute;"></div>
    <div id="IBox" style="top:20px; right:40px; position:absolute;">
        <input type="button" value="吹き出しを開く" onclick="openMsginfo();">
    </div>
</body>
</html>