Custom Widget - BaseFeatureAction Type Functionality in Experience Builder?

349
6
11-29-2021 12:29 PM
JonathanKressin
New Contributor III

I am currently working at rewriting Widgets that were written in WebAppBuilder to similar functionality in ExperienceBuilder.  One of the components I utilized in WAB was the BaseFeatureAction item.  That way, when a parcel was clicked, there were a number of different processes a user could select from the identification window.  Has anyone found a way to reproduce this in Experience Builder?  Or if not that specifically, is there a way to add other tools besides 'Zoom To' to the feature popup box?  

Any suggestions on best approaches to do something similar with this application would be appreciated.

 

Thanks!

Jonathan Kressin

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

@JonathanKressin 

I did it this way. In my custom widget that produces search results I add an action button to the popup template for the results featurelayer.

    let AssessReportAB = new ActionButton({
      title: "Assessment Report",
      id: "taxReport",
      image: require("./assets/Report-dark.svg")
    });
...

    let popUpInfo = {
      title: '{' + titleField + '}',
      content: this.getPTcontent,
      outFields: ["*"],
      actions: [AssessReportAB,taxBillAB,impReportAB,CoordReportAB]
    };
    var pt = new PopupTemplate(popUpInfo);

...

jimuMapView.view.popup.viewModel.on("trigger-action", function(event) {
        if(that.props.state === WidgetState.Opened){
          if (event.action.id === "taxReport") {
            let attributes = jimuMapView.view.popup.viewModel.selectedFeature.attributes;
            this.showTaxReport(attributes.PPIN, this.currentLayerAdded);
          }

 of course this route does not add the actions to any popup that appears in the app but that is actually exactly what I want in my scenario.

0 Kudos
MatiasTonelli1
New Contributor II

Hi @JonathanKressin 
Has anyone found a solution for this? The solution that @RobertScheitlin__GISP  posted isn't what I'm looking for. I'm specifically looking for a way to develop functions within the default popup of existing layers, akin to what BaseFeatureAction allowed in WebAppBuilder.

0 Kudos
JeffreyThompson2
MVP Regular Contributor

Take a look at the solutions to this post.

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-a-button-to-a-popup-using-the...

GIS Developer
City of Arlington, Texas
0 Kudos
MatiasTonelli1
New Contributor II

Thanks for the suggestion! @JeffreyThompson2  I took a look at the solutions in the provided link. However, it seems that those solutions involve instantiating new maps and views. I'm specifically looking for a way to achieve this using the existing map and view in my application. If you have any insights or alternative approaches within the context of the existing map, I'd greatly appreciate it!

0 Kudos
JeffreyThompson2
MVP Regular Contributor

You can grab the mapView from another widget. I have found these two lines of code work well most of the time. There are probably better more robust methods as well.

    const viewManager = MapViewManager.getInstance()
    const mapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])

 

GIS Developer
City of Arlington, Texas
0 Kudos
JonathanKressin
New Contributor III

I never found a satisfactory solution in dealing with the popup in the same way we had in the WebAppBuilder.  At the time, instead of fighting with that system, I created my own 'Identify' tool that allowed a local configuration per layer that I allow to be identified.  With that, I had full control of how the data was displayed and what options I had.  You can see what I ended up here:  https://mapping.kenoshacountywi.gov/InteractiveMapping/ You can zoom in and just click on a parcel and my custom widget handles everything in the sidebar.

Jonathan

 

 

 

0 Kudos