0
votes

Here is the rest service I'm working from: http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3

My current call for displaying the feature layer is as follows:

var recLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",{
    infoTemplate: recParkTemplate,
    outFields: ["STATE_NAME"]
  });
map.addLayer(recLayer);

However, instead of plotting the polygon on the map as this is an esriGeometricPolygon. I would rather have it plot on the map like a esriGeometryPoint. I know this method in getting the specific polygon's centroid:

https://developers.arcgis.com/javascript/jsapi/polygon-amd.html#getcentroid

My problem is I can't figure out how to cycle among all polygons in the feature layer and then plot those polygons. I can only point and click and display similar to how this ESRI sample works: https://developers.arcgis.com/javascript/jssamples/util_label_point.html

Thank you for your assistance. Here is the current site if you would like to take a look at it: http://joshferrell.net/ece_project/

1

1 Answers

0
votes

to cycle among all geometries in your feature layer you can do something like this:

            recLayer.on("update-end", function changeHandler(evt) {
            require(["dojo/_base/array"], function (array) {

                array.forEach(recLayer.graphics, function (entry, i) {
                    console.debug(entry, "at index", i);
                });
            });
        });

inside the loop use the getCentroid and add the result to the map