Select to view content in your preferred language

Changing FeatureLayer Properties

2753
6
01-21-2016 08:38 AM
TomLeMahieu
Deactivated User

This code is cloning an existing featurelayer and using the layerinfo to a create a new featurelayer.  I'm trying to turn off the popup for the new featurelayer.  How can I do this?  The code below does not work.  I get the resultLayer, but the popup remains.

var layerInfo = lang.clone(this.resultLayers[layerIndex]);        

var featureCollection = {

      layerDefinition: layerInfo,

      featureSet: null

};

resultLayer = new FeatureLayer(featureCollection, {

      mode: FEATURELAYER.MODE_SELECTION,

      popup: FeatureLayer.POPUP_NONE,

      outFields: ["PIN"]

});

0 Kudos
6 Replies
ReneRubalcava
Esri Frequent Contributor

What if you change it to htmlPopupType: FeatureLayer.POPUP_NONE?

FeatureLayer | API Reference | ArcGIS API for JavaScript

0 Kudos
TomLeMahieu
Deactivated User

I changed the code as follows:

        resultLayer.name = "xxxxxxxxxx";

        resultLayer.htmlPopupType = "esriServerHTMLPopupTypeNone";

I also tried

        resultLayer.htmlPopupType = 0;

The name takes affect as you can see in the Legend:

But the popup is still popping up.  Any ideas?

0 Kudos
SteveCole
Honored Contributor

I think what Rene was suggesting is this:

resultLayer = new FeatureLayer(featureCollection, {
      mode: FEATURELAYER.MODE_SELECTION,
      htmlPopupType: FeatureLayer.POPUP_NONE,
      outFields: ["PIN"]
});

0 Kudos
TomLeMahieu
Deactivated User

I should have been more clear.  I tried that and none of the 3 properties were changed:

resultLayer = new FeatureLayer(featureCollection, { 

     name: "xyz"

     htmlPopupType: FeatureLayer.POPUP_NONE, 

     outFields: ["PIN"]

});

At least when I used the following the name got changed so I think I'm on the right track:

        resultLayer.name = "xxxxxxxxxx";

        resultLayer.htmlPopupType = "esriServerHTMLPopupTypeNone";

     

0 Kudos
SteveCole
Honored Contributor

Ah. Well, this is something to try. Might get messy depending on other things you're doing in your app.

        resultLayer.on("click", function(evt) {
                map.infoWindow.set("popupWindow", false);
        });

That will prevent it from displaying but that also shuts it off for ALL OTHER layers in your map so you would also need listener events to "turn on" the popups for those layers:

        otherLayer.on("click", function(evt) {
                map.infoWindow.set("popupWindow", true);
        });
0 Kudos
KellyHutchins
Esri Frequent Contributor

Can you try setting the infoTemplate for the feature layer to null?

FeatureLayer | API Reference | ArcGIS API for JavaScript

0 Kudos