I'm having a little trouble accessing my feature layer in the Web Appbuilder app. If I did the following outside of WAB, just in a testing JS 3.x environment, it would work.
<script>
mode: FeatureLayer.MODE_AUTO,
outFields: "",
id: "myParcels"
})
map.addLayer(myFL);
myFL.on("click", function (evt) {
var geom = evt.graphic.geometry;
console.log(geom)
</script>
But in WAB, myFL already exists in there, so if I do map.addLayer(myFL), it's adding it a second time, but that's the only way I can successfully return anything on a click event.
If I do the following in WAB, not adding the layer (because it's already in the map and I don't want it twice), I can't return anything on the click event. I'm not sure what I'm missing that I can't return anything?? I feel like I've tried everything to access this layer, I've tried map.getLayer(id), and that didn't work. Not sure why it isn't working...
<script>
{
return declare(BaseWidget, {
//Derive from BaseWidget.
baseClass: 'jimu-widget-myWidget',
isActive: true,
startup: function() {
this.inherited(arguments);
outFields: ["*"]})
},
onOpen: function(){
this.myFL.on('click', function(evt){
var geom = evt.graphic.geometry;
console.log(geom)
})
}
});
});
</script>