AnsweredAssumed Answered

JS API 4.11 - Intercepting search widget result and changing symbol

Question asked by jay.gregory on Sep 25, 2020

I'm having a difficult time intercepting a search widget selected result and dynamically changing the symbol that gets placed on the map based on application state, and am curious if this workflow is supported.  At its most simplistic, I've tried with the below, which does not work.  

 

In my case, setting the resultSymbol on the search sources object or anything "hard-coded" would not work, since I have multiple application settings that might affect how I want a search result displayed - what's missing in the below code are the conditionals checking those application settings, but I wasn't even able to get the simple case to work.  

 

Can anyone help me out?

this.searchWidget.on('select-result', ({result, source})=>{
        result.feature.symbol = {
             type: "point-3d",  // autocasts as new PointSymbol3D()
             symbolLayers: [{
                  type: "object",  // autocasts as new ObjectSymbol3DLayer()
                  width: 20,  // diameter of the object from east to west in meters
                  height: 50,  // height of the object in meters
                  depth: 15,  // diameter of the object from north to south in meters
                  resource: { primitive: "cylinder" },
                  material: { color: "red" }
              }]
          };
});

Outcomes