Trying to highlight features click on in Exp Builder map

386
5
02-14-2024 01:23 PM
KoreyAlleman1
New Contributor

Hi, I am trying to customize the Exp Building Map Widget with a on click event to highlight and select the features I click on at that spot for instance both the building and parcel at that point.  The issue I am having is it will not highlight and I haven't been able to figure out why.

Here is my snippet of code in the widget.tsx file:

jmv.view.on("click", function(event) {        
        if(jmv) {  
          let myLayers: String = ""
          if (identifyLayers.trim() == "") {
            myLayers = bufferLayers;
          } else {
            myLayers = identifyLayers + "," + bufferLayers
          }
          const myClickableLayers = myLayers.split(',')
          const mapLyrVws = jmv.jimuLayerViews
          const dsObj = DataSourceManager.getInstance()
          for (const key in mapLyrVws) {
            const ds = mapLyrVws[key].id
            const lyrVw = mapLyrVws[key]    
            if (myClickableLayers.includes(lyrVw.layer.title)) {
              //if (lyrVw.layer.popupEnabled) {
                let query = lyrVw.layer.createQuery();
                query.geometry = jmv.view.toMap(event);
                query.returnGeometry = true;
                query.outFields = [ "*" ]
                lyrVw.layer.queryFeatures(query).then(function(results) {  
                  if (lyrVw.layer.title == "Buildings") { // || lyrVw.layer.title == "Parcel QL" || lyrVw.layer.title == "PARCEL No Buildings") {  
                    alert(lyrVw.type)
                    alert(results.features[0].attributes.OBJECTID)
                    lyrVw.selectFeatureById(results.features[0].attributes.OBJECTID)

                   
                    const myExtent = results.features[0].geometry.extent.expand(extent_level)
                    jmv.view.goTo(myExtent)                          
                  }
                })  
              //}  
            }            
          }
        }
      });
0 Kudos
5 Replies
JessicaRamirez1
New Contributor III

I used the highlight method. Here is the link to the sample code from ESRI.

https://developers.arcgis.com/javascript/latest/sample-code/highlight-point-features/

 

0 Kudos
KoreyAlleman1
New Contributor

Did you use a Web Map or a Web Scene for the Map Source?

0 Kudos
JessicaRamirez1
New Contributor III

I used a Web Map.

0 Kudos
KoreyAlleman1
New Contributor

I have tried that as well but so far it hasn't lit the feature.  Are you doing in the Map Widget?  Did you set it up in the widget.tsx?

0 Kudos
JessicaRamirez1
New Contributor III
0 Kudos