Openlayers ol.interaction.Select傳值問題

說明:

在使用ol.interaction.Select時,我定義的變量做用域做用不到其回調函數裏,但我在select結果中,須要用到這些變量函數

解決方案:

雖想了個辦法解決了,但不知道是否是合理;是否有其餘解決方法this

        let selecthover = new ol.interaction.Select({
            condition: ol.events.condition.click,
            layers: [animationLineLayer]
        });
        selecthover.set("arrPoints", that._pointArray);
        selecthover.on("select", function (evt) {
            var tmpPointsArray = this.getProperties()["arrPoints"];
        });
相關文章
相關標籤/搜索