earthSDK之點添加點擊事件


earthSDK之點添加點擊事件

點擊事件代碼:

//點擊事件
            pin.onclick = () => {
                console.log('點擊確認')
            }

注意:

點擊事件功能需在創建底圖時全局打開點擊事件權限,否則點擊事件不生效。

打開權限代碼:(添加在     let earth = new XE.Earth('earthContainer'     之后);

earth.interaction.picking.enabled = true
earth.interaction.picking.hoverEnable = false

添加點代碼:

   // 繪制點位
        createODPoints(earth, item, imgUrl) {
            // 度轉弧度
            function DtoR(val) {
                let r = (val * Math.PI) / 180
                return r
            }
            const objConfig = {
                name: 'Pin1',
                xbsjType: 'Pin',
                position: [DtoR(120.48), DtoR(39.52), 500],
                near: 20000,
                imageUrl: '/images/earth/img/station.png',
                disableDepthTestDistance: 0
            }
            const pin = new XE.Obj.Pin(earth)
            pin.xbsjFromJSON(objConfig)
            //點擊事件
            pin.onclick = () => {
                console.log('點擊確認')
            }
            return pin
        }

 

 

 

 

鑽研不易,轉載請注明出處......

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM