Add Pop-up to Draw Widget by Default

338
2
Jump to solution
07-01-2020 10:31 AM
MattPohl
Occasional Contributor II

In the draw widget's configuration, the user can choose to add the markup/drawing as an operational layer. I am wondering how I could enable a pop-up to the newly add layer by default? If the application has the OTB layer list widget, you can enable the popup there (as the new operational layer automatically gets added to the layer list), but I would like to skip that step and have the popup automatically enabled. Any help would be appreciated. 

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Matt,

  In the Widget.js make this change to the _addLayerFromLayerInfos function (lines 11-16):

      _addLayerFromLayerInfos: function(layer){
        var loading = new LoadingIndicator();
        loading.placeAt(this.domNode);
        LayerInfos.getInstance(this.map, this.map.itemInfo)
        .then(lang.hitch(this, function(layerInfos){
          if(!this.domNode){
            return;
          }
          loading.destroy();
          layerInfos.addFeatureCollection([layer], this.label + "_" + layer.name);
          setTimeout(() => {
            var layerInfo = layerInfos.getLayerInfoById(this.label + "_" + layer.name + "_0");
            if(layerInfo){
              layerInfo.enablePopup();
            }
          }, 1000);
          
        }), lang.hitch(this, function(err){
          loading.destroy();
          console.error("Can not get LayerInfos instance", err);
        }));
      },

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Matt,

  In the Widget.js make this change to the _addLayerFromLayerInfos function (lines 11-16):

      _addLayerFromLayerInfos: function(layer){
        var loading = new LoadingIndicator();
        loading.placeAt(this.domNode);
        LayerInfos.getInstance(this.map, this.map.itemInfo)
        .then(lang.hitch(this, function(layerInfos){
          if(!this.domNode){
            return;
          }
          loading.destroy();
          layerInfos.addFeatureCollection([layer], this.label + "_" + layer.name);
          setTimeout(() => {
            var layerInfo = layerInfos.getLayerInfoById(this.label + "_" + layer.name + "_0");
            if(layerInfo){
              layerInfo.enablePopup();
            }
          }, 1000);
          
        }), lang.hitch(this, function(err){
          loading.destroy();
          console.error("Can not get LayerInfos instance", err);
        }));
      },
0 Kudos
MattPohl
Occasional Contributor II

Works perfect. Thank you, Robert.

0 Kudos