標記點事件

標記點事件

標記點一般事件可以在標記點受到各種設定的改變時,觸發一系列的動作。加入監聽事件方法如下,詳細可參照範例:

function InitWnd() {

            var pBody = document.getElementById("TGMap");

            tg3dEarth = new TGOS.TEOnlineMap(pBody, null, function(){

            addMaker();

            });

            msgDiv = document.getElementById("Msg");

           }

function addMaker(){

            markerPoint = new TGOS.TEPoint(121.519470, 25.042010);

            markerImg = new TGOS.TEImage("http://api.tgos.tw/TGOS_API/images/marker.png", new TGOS.TESize(38, 33), new TGOS.TEPoint(0, 0), new TGOS.TEPoint(10,

            33));

            pTEMarker = new TGOS.TEMarker(tg3dEarth, markerPoint, "內政部", markerImg, null);

            //加入監聽事件方法

            TGOS.TEEvent.addListener(pTEMarker, "clickable_changed", function () { msgDiv.innerHTML = "改變點擊狀態" });

            TGOS.TEEvent.addListener(pTEMarker, "visible_changed", function () { msgDiv.innerHTML = "改變顯示狀態" });

            TGOS.TEEvent.addListener(pTEMarker, "title_changed", function () { msgDiv.innerHTML = "改變標題名稱" });

            TGOS.TEEvent.addListener(pTEMarker, "position_changed", function () { msgDiv.innerHTML = "改變位置" });

            TGOS.TEEvent.addListener(pTEMarker, "icon_changed", function () { msgDiv.innerHTML ="改變icon" });

            }

          

 

回到上方