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"]
});
What if you change it to htmlPopupType: FeatureLayer.POPUP_NONE?
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?
I think what Rene was suggesting is this:
resultLayer = new FeatureLayer(featureCollection, { mode: FEATURELAYER.MODE_SELECTION, htmlPopupType: FeatureLayer.POPUP_NONE, outFields: ["PIN"] });
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";
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); });
Can you try setting the infoTemplate for the feature layer to null?