Changes to Web appbuilder search widget code to configure geocoder search to trigger layer popup

488
0
06-16-2021 05:42 PM
BrandonPrice2
Occasional Contributor

Hello:

 

The code below allows me to trigger a popup for a layer in my web map instead of the default search result popup when using the geocoder search although it does not always work because the function processes before the layer has refreshed even with the extra setTimeout included. The layer has to refresh in order for it to work. How do I make a promise to not run the function until the layer has refreshed instead of using the setTimeout?

 

This the link to my web map: https://lacounty.maps.arcgis.com/home/webmap/viewer.html?webmap=c852a8eb23d74122851917613c9c5102 

This is the link to the layer: https://arcgis.gis.lacounty.gov/arcgis/rest/services/LACounty_Dynamic/CAMS/MapServer/1 

 

setTimeout(lang.hitch(this, function(){
          var mpPt;
          if(result.feature.geometry.type === "point"){mpPt = result.feature.geometry;}

          else{mpPt = result.feature.geometry.getExtent().getCenter();}
          var scrPt = this.map.toScreen(mpPt);
          this.map.emit("click", { 
            bubbles: true, 
            cancelable: true, 
            mapPoint: mpPt,
            screenPoint: scrPt
          });
        }),1200);

 

0 Kudos
0 Replies