I am trying to implement a popup action that allows a user to "pin" a selected feature to the map by adding it to the view's graphics layer (so it would remain even if the source layer is removed or turned off). I did not think this would be that hard but I have not been able to get the selected feature symbol (for cloning the graphic then adding to the graphics layer). I have tried it two different ways below -
One is by using the popup trigger action event, and getting the selected feature.
The second is using the layer's feature layer view and querying features within the extent.
Both get the graphics I need, except the symbol is missing - just the attributes and geometry.
Does anyone know what I'm doing wrong? Doesn't anyone have any other ideas of how to implement this feature?
mapView.popup.on("trigger-action", ({action, target}) => {
const selectedFeature = target.selectedFeature.clone();
console.log(selectedFeature.symbol) //this is null in my app
});
featureLayerView.queryFeatures(
{geometry: mapView.extent,
returnGeometry: true})
.then(featureSet=>{
console.log(featureSet); //this has all features in the current extent, but each graphic only contains geometry and attributes, not the symbol
});
Solved! Go to Solution.
Turns out symbolUtils is there to fix this exact problem. Who knew (I certainly didn’t when I asked this question)?
Turns out symbolUtils is there to fix this exact problem. Who knew (I certainly didn’t when I asked this question)?