【GIS】Leaflet要素信息及事件处理

onEachFeatureFlashForGeoJson(feature, layerObject) {
        let that = this;
        var elements = "";
        let i = 0;
        let properties = feature.properties;
        for (var item in properties) {
          let name = item;
          let value = properties[name];
          if (window.hideFields.indexOf(name) < 0 && value != null) {
            i++;
            if (i > 20) {
              break;
            }
            elements = elements + name + ":" + value + "<br>"
          }
        }
        if (elements != "") {
          layerObject.bindPopup(elements);
        } else {
          console.log("没有属性信息!")
        }
        layerObject.on({
          mouseover: this.highlightFeature,
          mouseout: this.resetHighlight,
          click: this.zoomToFeature
        }); 
      },

 

posted @ 2021-07-07 09:41  咸鱼翻身  阅读(310)  评论(0编辑  收藏  举报