Popup Panel Widget Customization

5270
23
Jump to solution
04-21-2016 07:15 AM
NatashaManzuiga
Regular Contributor

Hi all,

I'm trying to set a different behavior of the Popup Panel Widget on map click for each layer.

For a particular layer, I need to retrieve data from a webservice passing a field value as parameter.

Is it right what I'm trying to do or you think I have to move this code somewhere else?
at the moment the line 10 gave me an error:
TypeError: this.own is not a function

startup: function () {
    this.inherited(arguments);        
    var map = this.map;          
    LayerInfos.getInstance(map, map.itemInfo).then(lang.hitch(function(operLayerInfos) {  
    operLayerInfos.getLayerInfoArray().forEach(function(layerInfo) {  
            if (layerInfo.title == 'Map') {  
                var layerId = layerInfo.id;  
                console.log('layer ID = ', layerId);
                var layer = map.getLayer(layerId);
                this.own(on(layer, "click", lang.hitch(this, this.onMapClick)));                
                }
            }    
            );  
        }    
        ));  
    this.displayPopupContent(this.popup.getSelectedFeature());
},

onMapClick: function(event) { 
//I want to disable the normal behavior of the click (retrieve data and populate the Popup Panel widget with my customized content)
  var queryTask = new QueryTask('*Service URL*'); 
  var query = new Query(); 
  query.returnGeometry = true; 
  query.outFields = ['*'];  
  query.geometry = event.mapPoint; 
  queryTask.execute(query, lang.hitch(this, this.showResults)); 

  }, 
showResults: function(results) { 
  var resultItems = []; 
  var resultCount = results.features.length; 
  for (var i = 0; i < resultCount; i++) { 
      var featureAttributes = results.features.attributes; 
      var URL = "theWebServiceUrl" + featureAttributes.NAME; 
    //and I want to pass this URL to call it with through esri/request and retrieve data and then populate the PopUp Panel
      } 
  }

Thanks,

Naty

Tags (1)
0 Kudos
23 Replies
RobertScheitlin__GISP
MVP Emeritus

Naty,

  What version of WAB are you talking about?

0 Kudos
NatashaManzuiga
Regular Contributor

Hi Robert,

at startup of my widget I added this code

on(this.map.infoWindow, 'selection-change', lang.hitch(this, function() {

        this.replacePopUp();

      }));

I still have to understand this:

1) it seems like I 'm replacing the infoWindow content ....using the call this.map.infoWindow.setContent('bla bla bla') in replacePopUp....cause if I use a break before setContent in google chrome developer, I see the default content of the infoWindow.

Thanks,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

it seems like I 'm replacing the infoWindow content ....using the call this.map.infoWindow.setContent('bla bla bla') in replacePopUp

That is exactly what you are doing.

0 Kudos
NatashaManzuiga
Regular Contributor

Robert, yes it is.

But can I replace the infoWindow content..before the infoWindow default content is set and displayed?

Thanks,

Naty

0 Kudos