Is it possible to create points from polygons on the fly and display them on the web map ?
For example, if I go to style -> Choose attributes -> Expression, then I use the codes below to get the centroid. I click on "Test" and see it actually returns the centroid but I have no idea how to make the point returned show up on my map. Any help is greatly appreciated.
Yes, there are several ways to convert polygons to points by either using a geoprocessing tool called feature to point, or running a python script that gets the central x,y, or xy coordinates. Both of these methods can be made to use on the fly.
Is there a widget for web app builder out there for me to use ? My business case is users apply filters to get polygon features they want but when they zoom out too far those polygons are hard to see on the map. I'm thinking about having those features displayed as points at a certain map scale. Any idea or point of direction is greatly appreciated.
No, there currently isn't a widget that can do this automatically. But you can use a map-magical method that would make it appear as if your polygons are turning into points. Simply put, you can convert your polygons to points, set the scale for the points to display when the user zooms out and the polygons to not display from the set scale, and then set polygons to display in using the same scale for when the user zooms in and the points to not display.
This will make it seem like the polygons are turning into points, but they are simply displaying based on how far out or in the user zooms.
Hope this helps.
So there are other options (in tandem with the option I provided) using one of several methods.
Play around with these and see if any of these options to see which ones work for you.
@helenchu The Smart Editor widget in Web AppBuilder now supports creating points from polygons. Please see this blog: What’s New in the Smart Editor widget (June 2021) (esri.com)
Although it does require user input by selecting the features to be copied into the target point layer and it's not an automated process.