Friends
I want to create and display a single FeatureLayer from a different endpoint each time a tree node is clicked on.
The FeatureLayer should include symbology.
I pass in the Item.url with onClick and it works on the first pass.
The next .onClick is a different item.url and it bombs because it cannot create a new FeatureLayer.
TypeError: FeatureLayer is not a constructor
Suggestion on how to structure this.
Thanks
Keith
Solved! Go to Solution.
Change the name of your FeatureLayer variable to see if that makes any difference. It could be getting confused with the variable name assigned to the module "esri/layers/FeatureLayer",
featureLayer = new FeatureLayer(item.endpointurl, { mode: FeatureLayer.MODE_ONDEMAND, infoTemplate: infoTemplate, outFields: ["*"] }); featureLayer.setSelectionSymbol(fieldsSelectionSymbol); map.addLayer(featureLayer);
Change the name of your FeatureLayer variable to see if that makes any difference. It could be getting confused with the variable name assigned to the module "esri/layers/FeatureLayer",
featureLayer = new FeatureLayer(item.endpointurl, { mode: FeatureLayer.MODE_ONDEMAND, infoTemplate: infoTemplate, outFields: ["*"] }); featureLayer.setSelectionSymbol(fieldsSelectionSymbol); map.addLayer(featureLayer);
If you only want to show one layer at a time, then you could simply remove the old one "map.removeLayer(featureLayer)" and add in the new one. You'll get an error if you put in the same id for two different items.